📄 register.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="xwfb.connectDB" />
<%
String name = request.getParameter("user");
String password = request.getParameter("psw");
if(name == null || password == null)
{
%>
<html>
<head>
<title>注册新用户</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function add()
{
if(add_form.user.value.length == 0 || add_form.psw.value.length == 0 || add_form.psw1.value.length == 0)
{
alert("不能为空");
}
else
{
if(add_form.psw.value != add_form.psw1.value)
{
alert("密码不一致");
}
else
{
if(add_form.psw.value.length >50 || add_form.psw.value.length < 7)
{
alert("密码必须不小于7位,不超过50位");
}
else
{
add_form.submit();
}
}
}
}
</script>
</head>
<body>
<form name="add_form" action="register.jsp" method="get">
<table>
<tr>
<td width="100" class="text-login">用户名:</td>
<td width="120" class="text-login"><input type=text name="user" class="inputlength120" maxlength="20"></td>
</tr>
<tr>
<td width="100" class="text-login">密码:(不小于7位,不超过50位)</td>
<td width="120" class="text-login"><input type="password" name="psw" class="inputlength120" maxlength="20"></td>
</tr>
<tr>
<td width="100" class="text-login">确认密码:</td>
<td width="120" class="text-login"><input type="password" name="psw1" class="inputlength120" maxlength="20"></td>
</tr>
<tr>
<td><input type="button" value="提交" onclick="add()" class="logbutton"></td>
<td><input type="reset" value="重填" class="logbutton"></td>
</tr>
</table>
</form>
</body>
</html>
<%
}
else
{
//ResultSet rs = null;
try
{
String sql = "insert into XWFB_USER(username,password,priority) values('"+name+"','"+password+"','1')";
db.executeUpdate(sql);
%>
<script language="javascript">
alert("注册成功");
window.close();
</script>
<%
}
catch(Exception e)
{
session.setAttribute("error","1");
response.sendRedirect("error.jsp");
}
finally
{
try
{
db.closeDB();
//rs.close();
}
catch(Exception ee)
{
session.setAttribute("error","1");
response.sendRedirect("error.jsp");
}
}
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -