<%
if request("type")="save" then
qid=request.form("qid")
answer=request.Form("answer")
username=LCase(trim(request.form("UserName")))
password=md5(trim(request("password")))
password2=md5(trim(request("password2")))
email=request("email")
sex=request("sex")
city=trim(request("contactCity"))
petname=trim(request("petname"))
code=trim(request("code"))
ip = GettrueIP
'If ip = "" Then ip = Request.ServerVariables("REMOTE_ADDR")
ai=0
for ki=1 to len(username)
cit=0
cit=asc(mid(username,ki,1))
if cit>47 and cit<=57 then
'数字
ai=0
elseif cit>59 and cit<=90 then
'大写字符
elseif cit>96 and cit<=122 then
'小写字符
else
'特殊字符
ai=1
exit for
end if
next
if ai=1 then
errstr=errstr&"◎ 错误:用户名只能使用字母和数字的组合
"
end if
if request("password")<>request("password2") then
errstr=errstr&"◎ 错误:两次输入密码不一致
"
end if
if username="" then
errstr=errstr&"◎ 错误:请输入用户名
"
end if
if checkchinese(username)=true then
errstr=errstr&"◎ 错误:用户名只能为字母或数字
"
end if
if len(username)<3 or len(username)>12 then
errstr=errstr&"◎ 错误:超出长度限制,用户名必须为3-12个字母或数字
"
end if
if email="" then
errstr=errstr&"◎ 错误:E-mail地址不能为空
"
end if
if instr(cstr(email),"@") then
else
errstr=errstr&"◎ 错误:E-mail格式错误
"
end if
if petname="" then
errstr=errstr&"◎ 错误:请输入呢称
"
end if
if city="" then
errstr=errstr&"◎ 错误:请输入所在城市
"
end if
if sex="" then
errstr=errstr&"◎ 错误:请选择性别
"
end if
if trim(request("password"))="" then
errstr=errstr&"◎ 错误:密码不能为空
"
end if
if not isnumeric(qid) then
errstr=errstr&"◎ 错误:未知错误
"
end if
sql="select answer from autoquestion where id="&ccur(qid)
set rs=conn.execute(sql)
if rs.eof then
errstr=errstr&"◎ 错误:未知错误
"
else
rightanswer=cstr(trim(rs(0)))
end if
set rs=nothing
if errstr="" then
if instr(cstr(trim(answer)),rightanswer)>0 or cstr(trim(answer))=rightanswer then
else
errstr=errstr&"◎ 错误:验证答案错误
"
end if
sqluser = "select userid from [member] where username='" & Replace(username, "'", "") & "'"
set rs=conn.execute(sqluser)
If Not (rs.EOF Or rs.BOF) Then
errstr=errstr&"◎ 错误:用户名已经存在
"
Else
'IP检测
sqluser = "select regtime from [member] where datediff(""d"",regtime,getdate())=0 and userloginip='" & ip & "'"
set rs=conn.execute(sqluser)
If Not (rs.EOF Or rs.BOF) Then
if datediff("n",rs(0),now)<=300 then
errstr=errstr&"◎ 错误:同一IP五小时内只允许注册一个账号
"
end if
end if
if errstr="" then
conn.Execute ("insert into [member](username,password,email,sex,city,petnametmp,userloginip,userlogintime,msh,petname) values ('" & username & "','" & password & "','" & email & "'," & sex & "," & city & ",'"&petname&"','"&ip&"',getdate(),0,'"&petname&"')")
response.Cookies("pmusic")("username")=username
response.Cookies("pmusic")("petname")=petname
response.Cookies("pmusic")("kkcount")=0
response.Cookies("pmusic")("password")=password
response.Redirect("/member/member.html")
response.End()
end if
end if
end if
if errstr<>"" then
response.write ""&errstr&""
end if
end if
%>