📄 register.jsp
字号:
<%@ page language="java" contentType="text/html;charset=gb2312" import="wssd.*,java.sql.*"%>
<jsp:useBean id="db" class="wssd.connectDB" />
<jsp:useBean id="wd" class="wssd.wssdDB" />
<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 go(para)
{
if(para == 1)
{
if(add_form.username.value.length == 0 || add_form.password.value.length == 0 || add_form.psw.value.length == 0)
{
alert("不能为空");
}
else
{
if(add_form.password.value != add_form.psw.value)
{
alert("密码不一致");
}
else
{
add_form.submit();
}
}
}
if(para == 2)
{
add_form.reset();
}
}
</script>
</head>
<body>
<%
String username = request.getParameter("username");
if(username == null || username.length() == 0)
{
%>
<form name="add_form" action="register.jsp" method="post">
<table>
<tr>
<td class="text-login" align="right">*用户名:</td>
<td class="text-login"><input type="username" name="username" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">*密码:</td>
<td class="text-login"><input type="password" name="password" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">*密码确认:</td>
<td class="text-login"><input type="password" name="psw" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">姓名:</td>
<td class="text-login"><input type="text" name="name" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">年龄:</td>
<td class="text-login"><input type="text" name="age" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">性别:</td>
<td class="text-login">
<select name="sex" class="inputlength120">
<%
for(int i=0; i<KeyWord.sex.length; i++)
{
%>
<option value=<%=i%>><%=KeyWord.sex[i]%></option>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td class="text-login" align="right">Email:</td>
<td class="text-login"><input type="text" name="email" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">联系电话:</td>
<td class="text-login"><input type="text" name="phone" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login"><input type="button" value="注册" onclick="go(1)" class="logbutton"></td>
<td class="text-login"><input type="button" value="重填" onclick="go(2)" class="logbutton"></td>
</tr>
</table>
</form>
<%
}
else
{
String psw = request.getParameter("psw");
String name = new String((request.getParameter("name")).getBytes("ISO8859_1"));
String sex = request.getParameter("sex");
String age = request.getParameter("age");
String email = request.getParameter("email");
String phone = request.getParameter("phone");
comuserTable ct = new comuserTable();
ct.setUsername(username);
ct.setPassword(psw);
ct.setName(name);
ct.setSex(sex);
ct.setAge(age);
ct.setEmail(email);
ct.setPhone(phone);
int i = wd.insertComUser(ct);
if(i == 1)
{
%>
<script language="javascript">
alert("注册成功");
window.close();
</script>
<%
}
else
{
%>
<script language="javascript">
alert("注册失败");
window.close();
</script>
<%
}
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -