<!--#Include file="include/conn.asp"-->
<%'------获取传递过来的表单数据
userName_form=Trim(Request.Form("userName"))
passWord_form=Trim(Request.Form("passWord"))
userSex_form=Request.Form("userSex")
EMail_form=Trim(Request.Form("Email"))
regDate=Date()&" "&Time()
trueName_form=Trim(Request.Form("trueName"))
getConn()
'------判断填写的用户名是否已被注册
checkUserNameSql="select * from UserInfo where UserName='"&userName_form&"'"
Set checkUserNameRs=conn.Execute(checkUserNameSql)
'若用户名已存在，则返回前一页，保持表单中填写的内容不变
If not checkUserNameRs.Eof Then
  errmsg="用户名已存在，请重新填写！"
  returnURL="javascript:history.back();"
'若用户名未被使用，则插入用户表中一条记录，注册成功
Else
  registerSql="insert into UserInfo(UserName, PassWord, Sex, EMail, TrueName,RegDate, UserLevel) values ('"&userName_form&"','"&passWord_form&"','"&userSex_form&"','"&EMail_form&"', '"&TrueName_form&"', '"&regDate&"','1')"
  conn.execute(registerSql)
  Session("userName")=userName_form
  errmsg="注册成功！自动登录通讯录！"
  returnURL="index.asp"
End If
Set checkUserNameRs=Nothing
Set conn=Nothing
%>
<HTMl>
<HEAD>
<META http-equiv="Refresh" content='1;URL=<%=returnURL%>'>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<P align="center"><%=errmsg%>
</BODY>
</HTMl>
