<!--#include file=conn.asp-->
<!--#include file=const.asp -->
<!--#include file=md5.asp -->
<% dim rs , exec %>
<html>
<head>
<META name="Author" content="木鸟">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=sitetitle%></title>
<link rel="stylesheet" href="style/<%=skin%>.css" type="text/css">
</head>

<body>
<!--#include file="head.asp"-->
<br>
<table border="0" width="400" cellspacing="0" cellpadding="10" bordercolorlight="#000000" bordercolordark="#FFFFFF" align="center" class="table004">
 <tr> 
  <td class=table003 align=center>用户注册
  </td>
  </tr>
  <tr>
  
  <td class="table001" align="center"> 
<%
main()
connclose()

sub main()
	dim backInput, homeInput

	backInput= "<br><br><input type=button value=返回前页 onClick=history.back() class=input2 name=button ><br>"
	homeInput="<br><br><input type=button value=进入留言本首页 onClick=""location.href='index.asp' "" class=input2><br>"

	if request.form="" then
%>

   <form name="form1" method="post">
	<table width="80%" border="0">
	 <tr> 
	  <td width="30%">用 户 名：</td>
	  <td width="70%"> 
	   <input type="text" name="name" size="20" class="input1" value="" maxlength="20">
	  </td>
	</tr>
	 <tr> 
	  <td>密 　 码：</td>
	  <td> 
	   <input type="password" name="pass" size="20" class="input1" value="" maxlength="10" >
	  </td>
	 </tr>
	<tr>
	  <td>性　　别：</td>
	  <td >
	   <input type="radio" name="male" value="1" checked>男
	   <input type="radio" name="male" value="0" >女
	 （已注册用户不用填）
	  </td>
	 </tr>
	 <tr> 
	  <td>头　　像：</td>
	  <td >
	   <a href=### onclick=window.open("face.asp","face","width=400,height=400,resizable=1,scrollbars=1") title=点击选择头像>
	   <img src="<%if theUser.face<>"" then response.write theUser.face else response.write "face/m01.gif"%>" border=0 id="faceImg"></a>
	   <input class="input1"  type=hidden name="face" value="face/m01.gif">
	  </td>
	 </tr>
	 <tr> 
	  <td>电子邮件：</td>
	  <td> 
	   <input type="text" name="email" size="20" class="input1" value=""  maxlength=30>
	  </td>
	 </tr>
	 <tr> 
	  <td>　 QQ 　：</td>
	  <td>
	   <input type="text" name="qq" size="20" class="input1" value=""  maxlength=10>
	  </td>
	 </tr>
	 <tr> 
	  <td>　 ICQ &nbsp;：</td>
	  <td>
	   <input type="text" name="icq" size="20" class="input1" value=""  maxlength=10>
	  </td>
	 </tr>
	 <tr> 
	  <td>　 MSN &nbsp;：</td>
	  <td>
	   <input type="text" name="msn" size="20" class="input1" value=""  maxlength=100>
	  </td>
	 </tr>
	 <tr> 
	  <td>主页地址：</td>
	  <td> 
	   <input type="text" name="url" size="30" value="http://" class="input1"  maxlength=50>
	  </td>
	 </tr>
	 <tr align="center"> 
	  <td colspan="2" height="40"> 
	   <input type="submit" value=" 注 册 " class="input2" name="Submit" >
	  </td>
	</tr>
   </table>
   </form>
<%
	else
		dim name, pass, male,face,email,qq,url,icq,msn
		name=Encodestr(request.form("name"))
		pass=Encodestr(request.form("pass"))
		male=Encodestr(request.form("male"))
		face=Encodestr(request.form("face"))
		email=Encodestr(request.form("email"))
		qq=Encodestr(request.form("qq"))
		url=Encodestr(request.form("url"))
		icq=Encodestr(request.form("icq"))
		msn=Encodestr(request.form("msn"))
		
		if name="" or pass="" then
			response.write "<font color=red>发生错误</font><br><br>请输入用户名和密码！！！"
			response.write backInput
			exit sub
		end if
		
		if not validEmail(email) then
			response.write "<font color=red>发生错误</font><br><br>请输入正确的email地址！！！"
			response.write backInput
			exit sub
		end if
		
		pass=MD5(pass)
		
		if isLikeMasterName(name) then
			response.write "<font color=red>发生错误</font><br><br>请不要使用与版主名相似的用户！！！"
			response.write backInput
			exit sub
		end if
		
		exec="select * from [user] where username='"&name&"' "
		set rs=server.createobject("adodb.recordset")
		rs.open exec,conn,1,3
		if not (rs.eof and rs.bof) then
			rsclose()
			response.write "<font color=red>发生错误</font><br><br>该用户名已被注册，请选择其它用户名！！！"
			response.write backInput
			exit sub
		end if
		rs.Addnew
		rs("username")=name
		rs("userpassword")=pass
		rs("sex")=male
		rs("GBface")=face
		if email<>"" then
			rs("useremail")=email
		end if
		if qq<>"" then
			rs("oicq")=qq
		end if
		if icq<>"" then
			rs("icq")=icq
		end if
		if msn<>"" then
			rs("msn")=msn
		end if
		if url<>"" then
			rs("homepage")=url
		end if
		rs("GBpostNum")=0
		rs("GBprivateNum")=0
		rs("addDate")=now
		
		rs.update
		rsclose()
		response.write "<font color=red>注册成功！！！</font>"
		response.write homeInput
		
		if cookiePath<>"" then
			response.cookies("gbook").Path=cookiePath
		end if
		response.cookies("gbook")("username")=vbescape(name)
		response.cookies("gbook")("password")=pass

	end if
end sub %>
   </td>
 </tr>
</table>
<!--#include file="foot.asp"-->

</body>

</html>
