%
Founderr=false
dim username,answer,password
stats="密码遗忘"
call nav()
call headline(1)
if founderr then
call error()
else
if request("action")="step1" then
call step1()
elseif request("action")="step2" then
call step2()
elseif request("action")="step3" then
call step3()
else
call main()
end if
if founderr then call error()
end if
call endline()
sub step1()
if request("username")="" then
Founderr=true
Errmsg=Errmsg+"
"+"
请输入您的用户名。"
exit sub
else
username=replace(request("username"),"'","")
end if
set rs=conn.execute("Select Quesion,Answer,Username from [user] where username='"&username&"'")
if rs.eof and rs.bof then
Founderr=true
Errmsg=Errmsg+"
"+"您输入的用户名并不存在,请重新输入。"
else
if rs(0)="" or isnull(rs(0)) then
Founderr=true
Errmsg=Errmsg+"
"+"该用户没有填写密码问题及答案,只有填写的用户方能继续。"
else
%>
<%
end if
end if
rs.close
set rs=nothing
end sub
sub step2()
if request("username")="" then
Founderr=true
Errmsg=Errmsg+"
"+"请输入您的用户名。"
exit sub
else
username=replace(request("username"),"'","")
end if
if chkpost=false then
ErrMsg=ErrMsg+"
"+"您提交的数据不合法,请不要从外部提交发言。"
FoundErr=True
exit sub
end if
if request("answer")="" then
Founderr=true
Errmsg=Errmsg+"
"+"请输入您的问题答案。"
exit sub
else
answer=md5(request("answer"))
end if
set rs=conn.execute("select answer,quesion from [user] where username='"&username&"' and answer='"&answer&"'")
if rs.eof and rs.bof then
Founderr=true
Errmsg=Errmsg+"
"+"您输入的问题答案不正确,请重新输入。"
else
%>
<%
end if
rs.close
set rs=nothing
end sub
sub step3()
if request("username")="" then
Founderr=true
Errmsg=Errmsg+"
"+"请输入您的用户名。"
exit sub
else
username=replace(request("username"),"'","")
end if
if request("answer")="" then
Founderr=true
Errmsg=Errmsg+"
"+"请输入您的问题答案。"
exit sub
else
answer=md5(request("answer"))
end if
if request("password")="" then
Founderr=true
Errmsg=Errmsg+"
"+"请输入您的新密码。"
exit sub
elseif request("repassword")="" then
Founderr=true
Errmsg=Errmsg+"
"+"请再次输入您的新密码。"
exit sub
elseif request("password")<>request("repassword") then
Founderr=true
Errmsg=Errmsg+"
"+"您输入的新密码和确认不一样,请确认您填写的信息。"
exit sub
else
password=md5(request("password"))
end if
set rs=server.createobject("adodb.recordset")
sql="select userpassword,quesion from [user] where username='"&username&"' and answer='"&answer&"'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
Founderr=true
Errmsg=Errmsg+"
"+"您输入的问题答案不正确,请重新输入。"
else
rs("userpassword")=password
rs.update
%>
<%
end if
rs.close
set rs=nothing
end sub
sub main()
%>
<%
end sub
%>