2021.4.13

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.ch7.model.BlogInfo"%>
<%@page import="com.ch7.common.DataValidator"%>
<%@page import="com.ch7.common.Utility"%>
<%@page import="com.ch7.dal.Class"%>
<%@page import="com.ch7.model.ClassInfo"%>
<%@page import="com.ch7.model.UserInfo"%>
<%@page import="com.ch7.dal.Users"%>
<%@page import="com.ch7.common.MD5"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%
    request.setCharacterEncoding("utf-8");
    String action = request.getParameter("action");
    UserInfo info = new UserInfo();
    Users user = new Users();
    if ("reg".equals(action)) {
        if (user.isExistUsersInfo(request.getParameter("txtUserName")))
            out.println("<script>alert('用户已存在');window.location.href='register.jsp';</script>");
        else {
            info.setUsername(request.getParameter("txtUserName"));
            info.setPassword(MD5.Encrypt(request.getParameter("txtPassword")));
            info.setEmail(request.getParameter("txtEmail"));
            info.setPower("user");
            user.insert(info);
            out.println("<script>alert('注册成功');window.location.href='index.jsp';</script>");
        }
    }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>用户注册</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

</head>

<body background="Image/timg.jpg" width=100% height=100%>




<div class="header">

    <div id="content">
    <form id="form1" name="form1" method="post" action="register.jsp?action=reg">
    <table width="100%" border="0">
    <td><center>用户注册</center></td>
    <tr>
    <td>用户名</td>
    <td>
    <input type="text" name="txtUserName" id="txtUserName" width="500px"/>
    </td>
    </tr>
    <tr>
    <td>密码</td>
    <td>
    <input type="password" name="txtPassword" width="500px"/> 
    </td>
    </tr>
    <tr>
    <td>
    Email
    </td>
    <td> 
    <input type="text" name="txtEmail" width="500px"/>
    </td>
    </tr>
    <tr>
    <td colspan="2">
        <input type="submit" name="button" id="button" value="注册"/>
        <input type="reset" name="button" id="button" value="重置"/>
    </td>
    </tr>
    
    </table>
    </form>
    </div>
</body>
</html>
原文地址:https://www.cnblogs.com/sunhongbin/p/14941323.html