📄 index.jsp
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ include file="JSP/OPENDB.jsp"%>
<%!
String replacenull(String a){
if(a==null){
return " ";
}else{
return a;
}
}
%>
<%
String oabusyname = (String) session.getValue("oabusyname");
String oabusyusername = (String) session.getValue("oabusyusername");
String oabusyuserdept = (String) session.getValue("oabusyuserdept");
String oabusyuserlevel = (String) session.getValue("oabusyuserlevel");
if((oabusyusername==null)|(oabusyusername=="")){
response.sendRedirect("index.jsp");
}%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="css/css.css">
<script language="javascript1.2" src="js/openwin.js"></script>
<title>人事管理系统</title>
</head>
<body topmargin="5" leftmargin="5">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td height=68>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="68">
<tr>
<center>
<table>
<tr>
<td><b>注册新用户</b> </td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=top>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign=top height=280>
<%request.setCharacterEncoding("GB2312");
String submit1="注册";
if(submit1.equals(request.getParameter("submit")))
{
String username=request.getParameter("username");
password=request.getParameter("password");
String name=request.getParameter("name");
String userdept=request.getParameter("userdept");
String userlevel=request.getParameter("userlevel");
//判断是否有与申请的用户名相同的
String sql1="select * from scott.userinf where username='"+username+"' ";
ResultSet rs=stmt.executeQuery(sql1);
if(rs.next()){
%>
<center>
<br><br>
<font color=red>用户名为<%=username%>的用户已经存在,请选择其他用户名</font><br>
<a href="index.jsp">返回</a>
</center>
<%
}else{
stmt.executeUpdate("INSERT INTO scott.userinf(username,password,name,userdept,userlevel) VALUES('"+username+"', '"+password+"','"+name+"','"+userdept+"','"+userlevel+"')");
%>
<br><br>
<center>
<font color=red>用户名为<%=username%>的用户注册成功!</font>
<a href="login.jsp">返回</a>
</center>
<%
}
}else{
%>
<br>
<center>
<script Language="JavaScript">
function maxlength(str,minl,maxl) {
if(str.length <= maxl && str.length >= minl){return true;}else{return false;}
}
function form_check(){
var l1=maxlength(document.form2.username.value,1,20);
if(!l1){window.alert("用户名的长度大于1位小于20位");document.form2.username.focus();return (false);}
var l2=maxlength(document.form2.password.value,1,20);
if(!l2){window.alert("密码的长度大于1位小于20位");document.form2.password.focus();return (false);}
var a1=document.form2.password.value;
var a2=document.form2.repassword.value;
if(a1!=a2){window.alert("两次输入的密码应相同");document.form2.repassword.focus();return (false);}
var l3=maxlength(document.form2.name.value,1,20);
if(!l3){window.alert("姓名的长度大于1位小于20位");document.form2.name.focus();return (false);}
}
</script>
<form action="index.jsp" method=post name="form2" onsubmit="return form_check();">
<table border=2>
<tr>
<td>
用户名:</td><td><input type=text name="username" size=20><font color=red>*</font>
</td>
</tr>
<tr>
<td>
密码:</td><td><input type="password" name="password" size=20><font color=red>*</font>
</td>
</tr>
<tr>
<td>
密码确认:</td><td><input type="password" name="repassword" size=20><font color=red>*</font>
</td>
</tr>
<tr>
<td>
姓名:</td><td><input type="text" name="name" size=20><font color=red>*</font>
</td>
</tr>
<tr>
<td>
性别:</td><td><input type="text" name="sex" size=20><font color=red>*</font>
</td>
</tr>
<tr>
<td>
联系方式:</td><td><input type="text" name="phone" size=20>
</td>
</tr>
<tr>
<td>
部门:</td><td>
<select size=1 name="userdept">
<%
//打开数据库读出部门
String sql="select * from scott.dept1";
ResultSet rs1=stmt.executeQuery(sql);
while(rs1.next())
{
%>
<option value="<%=rs1.getString("dept")%>"><%=rs1.getString("dept")%></option>
<%
}
%>
</select><font color=red>*</font>
</td>
</tr>
<tr>
<td>
职位:</td><td><select name="userlevel" size=1>
<option value="总管">总管</option>
<%
//打开数据库读出职位
sql="select DISTINCT userlevel from scott.userlevel";
ResultSet rs2=stmt.executeQuery(sql);
while(rs2.next())
{
%>
<option value="<%=rs2.getString("userlevel")%>"><%=rs2.getString("userlevel")%></option>
<%
}
%>
</select><font color=red>*</font>
</td>
</tr>
<tr>
<td colspan="2" align=center>
带<font color=red>*</font>必须填 <input type="submit" name="submit" value="注册">
</td>
</tr>
</table>
</form>
</center>
<%
}
%>
</td>
</tr>
</table>
</tr>
<tr>
<td height=19>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="19">
</table>
</td>
</tr>
</table>
<%@ include file="foot.jsp"%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -