<jsp:useBean id="db" scope="page" class="chatweb.conn" />
<%@include file="../Common.jsp" %>
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Register</title>
<style type="text/css">
<!--
.f {
	font-size: 12px;
}
-->
</style>
<link href="../chat.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#FFF7DD">
<div align="center">
<br>
  <br>
  <br>
  <%
String regname=request.getParameter("username");
if(regname!=null&&regname!=""){
	String regpass=request.getParameter("password");
	//regname=getStr(regname);
	//regpass=getStr(regpass);
	int reg=db.register(regname,regpass);
	switch(reg){
		case 1:
			out.println("用户<B> "+getStr(regname)+" </B>注册成功,你可以用该用户名<a href=\"login.jsp\">登陆</a>了");
			break;
		case 2:
			out.println("用户名已经存在,请选择另外的用户名");
			break;
		case 3:
			out.println("数据插入异常!!!");
			break;
		default:
			out.println("未知错误");
			break;
	}
}
else{%>
  <script language="JavaScript" type="text/JavaScript">
function check(){
	var logname=document.all.username.value;
	if(logname==""){
		window.alert("还要请你输入用户名,真是郁闷");
	}
	else
	if(logname.indexOf("<")>=0||logname.indexOf(">")>=0||logname.indexOf("\"")>=0||logname.indexOf("'")>=0){
		window.alert("用户名不能包含 <、>、\'或\" ");
	}
	else
   	if(document.all.password.value!=document.all.rpassword.value){
		window.alert("两次输入的密码不一致");
		}
    	else {
	     document.all.form1.submit();
	  }
	}
</script>
  <form name="form1" method="post" action="">
    <table width="200" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td nowrap>&nbsp;</td>
        <td class="f"><div align="right">点这里回<a href="login.jsp">登陆页面</a></div></td>
      </tr>
      <tr>
        <td nowrap> <div align="right">Username:</div></td>
        <td><div align="left">
            <input name="username" type="text" id="username">
          </div></td>
      </tr>
      <tr>
        <td nowrap> <div align="right">Password:</div></td>
        <td><div align="left">
            <input name="password" type="password" id="password">
          </div></td>
      </tr>
      <tr>
        <td nowrap> <div align="right">Password Again:</div></td>
        <td><div align="left">
            <input name="rpassword" type="password" id="rpassword">
          </div></td>
      </tr>
      <tr>
        <td height="40" colspan="2"> <div align="right"></div>
          <div align="center">
            <input type="button" name="Submit" value="提 交" onClick="check()">
            <input type="reset" name="Submit2" value="重 置">
          </div></td>
      </tr>
    </table>
  </form>
<%
}
%>
</div>
</body>
</html>