<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="include/md5code.asp" -->
<!--#include file="include/function.asp" -->
<!--#include file="include/connect.asp" -->
<%
validatecode=request.form("validatecode")
if validatecode="" or Session("cnbruce.com_ValidateCode") <>validatecode then
Response.write("<script>alert('验证码不符，请返回确认！');window.location.replace('userreg.asp');</script>")
response.end()
end if

   Dim UserAlready,DomainAlready,EmailAlready
   Set UserAlready=Cn.Execute("SELECT Username FROM Show5_ALLUser WHERE Username='"&CheckStr(Request.Form("username"))&"'")
   Set EmailAlready=Cn.Execute("SELECT Email FROM Show5_ALLUser WHERE Email='"&CheckStr(Request.Form("email"))&"'")
   IF NOT(UserAlready.EOF AND UserAlready.BOF) Then
      Response.write("<script>alert('用户名已被注册！');window.location.replace('userreg.asp');</script>")
   ElseIF NOT(EmailAlready.EOF AND EmailAlready.BOF) Then
      Response.write("<script>alert('此邮箱地址已被注册！');window.location.replace('userreg.asp');</script>")
   Else
      set rs = server.CreateObject("adodb.recordset")
	  sql="select * from Show5_ALLUser where UserID is null"
	  rs.open sql,cn,1,3
	  rs.addnew
	  rs("Username")=request.form("username")
	  rs("Password")=md5(request.form("password"))
	  rs("Nickname")=request.form("nickname")
	  rs("Truename")=request.form("truename")
	  rs("Sex")=request.form("sex")
	  rs("Birthday_Year")=request.form("year")
	  rs("Birthday_Month")=request.form("month")
	  rs("Birthday_Day")=request.form("day")
	  rs("Province")=request.form("province")
	  rs("City")=request.form("city")
	  rs("Email")=request.form("email")
	  rs("Hompyname")=request.form("username")&"的宅基地"
	  rs("Selfintro")="欢迎光临我的宅基地！"
	  rs("Userpic")="user_photo.gif"
	  rs.update
	  Reg_Title="注册成功"
	  Reg_Message="欢迎注册秀我网用户~<br><br><a href='default.asp'>返回主页</a>"
	  Cn.Execute("Insert into Show5_Articlegroup(Username,Groupname) values('"&rs("Username")&"','默认分类')")
	  Cn.Execute("Insert into Show5_Photogroup(Username,Groupname) values('"&rs("Username")&"','默认分类')")
	  Cn.Execute("Insert into Show5_TTgroup(Username,Groupname) values('"&rs("Username")&"','默认分类')")
	  Cn.Execute("Insert into Show5_Videogroup(Username,Groupname) values('"&rs("Username")&"','默认分类')")
	  session("username")=rs("Username")
	  session("Userpic")=rs("Userpic")
	  response.redirect "default.asp"
   End IF
%>