<!--#include file="Include/Const.Asp"-->
<!--#include file="Include/NoSQL.Asp" -->
<!--#include file="Include/ConnSiteData.Asp"-->
<!--#include file="Include/Md5.Asp"-->
<%
If DateDiff("s", session("time"), Now())<Refresh Then
    response.Write "<script language='JavaScript'>alert('防刷新机制启动：请不要在 "&Refresh&" 秒内重复刷新！');" & "history.back()" & "</script>"
    response.End
Else
    session("time") = Now()
End If
Dim mMemName, mRealName, mSex, mPassword, mQuestion, mAnswer, mCompany, mAddress, mZipCode, mTelephone, mFax, mMobile, mEmail, mHomePage
Dim vPassword, CheckCode
Dim rs, sql
mMemName = Trim(request.Form("MemName"))
mRealName = Trim(request.Form("RealName"))
mSex = Trim(request.Form("Sex"))
mPassword = Trim(request.Form("Password"))
vPassword = Trim(request.Form("vPassword"))
mQuestion = Trim(request.Form("Question"))
mAnswer = Trim(request.Form("Answer"))
mCompany = Trim(request.Form("Company"))
mAddress = Trim(request.Form("Address"))
mZipCode = Trim(request.Form("ZipCode"))
mTelephone = Trim(request.Form("Telephone"))
mFax = Trim(request.Form("Fax"))
mMobile = Trim(request.Form("Mobile"))
mEmail = Trim(request.Form("Email"))
mHomePage = Trim(request.Form("HomePage"))
CheckCode = Trim(request.Form("CheckCode"))
Dim ErrMessage, ErrMsg(13), FindErr(13), i
ErrMsg(0) = "用户名必须为0-9,a-z,-_任意组合的3-16个字符。"
ErrMsg(1) = "用户名重复，请返回修改。"
ErrMsg(2) = "用户密码长度请保持在6-16位。"
ErrMsg(3) = "两次输入的用户密码不一致，请返回修改。"
ErrMsg(4) = "密码保护问题长度请保持在3-100个任何字符。"
ErrMsg(5) = "密码保护答案长度请保持在3-100个任何字符。"
ErrMsg(6) = "单位名称、详细地址长度请保持在100个字符以内。"
ErrMsg(7) = "请正确填写邮政编码。"
ErrMsg(8) = "请正确填写真实姓名、联系电话、传真号码、手机号码、网址。"
ErrMsg(9) = "电子信箱格式错误。"
ErrMsg(10) = "电子信箱已经注册过，请返回修改。"
ErrMsg(11) = "验证码不能为空，请返回检查。"
ErrMsg(12) = "您在【会员注册】页面停留的时间过长，导致验证码失效。\n请返回并刷新【会员注册】页面重新注册！"
ErrMsg(13) = "您输入的验证码和系统产生的不一致，请重新输入。"
If Not IsValidMemName(mMemName) Then FindErr(0) = True
If Not conn.Execute("select MemName from Shenbi_Members where MemName='" & mMemName & "'").EOF Then FindErr(1) = True
If Not (6<= Len(mPassword) And Len(mPassword)<= 16) Then FindErr(2) = True
If mPassword<>vPassword Then FindErr(3) = True
If Not (3<= Len(mQuestion) And Len(mQuestion)<= 100) Then FindErr(4) = True
If Not (3<= Len(mAnswer) And Len(mAnswer)<= 100) Then FindErr(5) = True
If Len(mCompany) = 0 Or Len(mCompany)>100 Or Len(mAddress) = 0 Or Len(mAddress)>100 Then FindErr(6) = True
If Len(mZipCode)<>6 Then FindErr(7) = True
If Len(mRealName) = 0 Or Len(mTelephone) = 0 Or Len(mFax) = 0 Or Len(mMobile) = 0 Or Len(mHomePage) = 0 Or Len(mRealName)>50 Or Len(mTelephone)>50 Or Len(mFax)>50 Or Len(mMobile)>50 Or Len(mHomePage)>50 Then FindErr(8) = True
If Not IsValidEmail(mEmail) Then FindErr(9) = True
If Not conn.Execute("select MemName from Shenbi_Members where Email='" & Email & "'").EOF Then FindErr(10) = True
If CheckCode = "" Then FindErr(11) = True
If Trim(Session("CheckCode")) = "" Then FindErr(12) = True
If CheckCode <> Session("CheckCode") Then FindErr(13) = True
For i = 0 To UBound(FindErr)
    If FindErr(i) = True Then
        ErrMessage = ErrMessage+ErrMsg(i) + "\n"
    End If
Next
If Not (ErrMessage = "" Or IsNull(ErrMessage)) Then
    WriteMsg(ErrMessage)
    response.End
End If
Set rs = server.CreateObject("adodb.recordset")
sql = "select * from Shenbi_Members"
rs.Open sql, conn, 1, 3
rs.addnew
rs("MemName") = mMemName
rs("RealName") = StrReplace(mRealName)
rs("Sex") = mSex
rs("Password") = Md5(mPassword)
rs("Question") = StrReplace(mQuestion)
rs("Answer") = Md5(mAnswer)
rs("Company") = StrReplace(mCompany)
rs("Address") = StrReplace(mAddress)
rs("ZipCode") = StrReplace(mZipCode)
rs("Telephone") = StrReplace(mTelephone)
rs("Fax") = StrReplace(mFax)
rs("Mobile") = StrReplace(mMobile)
rs("Email") = mEmail
rs("HomePage") = StrReplace(mHomePage)
rs("GroupID") = "200709088888888888"
rs("GroupName") = GroupName("200709088888888888")
rs("AddTime") = Now()
rs.update
rs.Close
Set rs = Nothing
response.Write "<script language='javascript'>alert('注册成功，请登录！');location.replace('Index.Asp');</script>"
response.End

Function GroupName(GroupID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from Shenbi_MemGroup where GroupID='"&GroupID&"'"
    rs.Open sql, conn, 1, 1
    GroupName = rs("GroupName")
    rs.Close
    Set rs = Nothing
End Function
%>