📄 usergetpass.asp
字号:
<html>
<!--#include file="head.asp"-->
<title><%=NetName%> - 找回密码</title>
<%
if (Request("action")="chk") then
call ReSendPsw
end if
%>
<body>
<!--#include file="toper.asp"-->
<table width="750" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<table width="750" height="10" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align=left><%
if Session("Id")<>"" and Session("UserName")<>"" then
response.write "<br>"
call ShowMenu
response.write "<br>"
end if%></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" width="500" align="center" border="0">
<tr><td>
<DIV style="PADDING-RIGHT: 25px; PADDING-LEFT: 43px; PADDING-BOTTOM: 12px; PADDING-TOP: 12px">
<%=ShowContent%><br><br>
<%
if session("Errmsg") <> "" then
response.write "· 在尝试处理您的密码取回请求时发生了以下错误:<br>"
response.write "<font color=red>"
response.write session("Errmsg")
response.write "</font>"
session("Errmsg") = ""
end if
%>
<FORM id=form1 name=form1 action=usergetpass.asp?action=chk method=post>
用户名称: <INPUT size=25 name=uname> <BR>
电子信箱: <INPUT size=25 name=email> <BR>
验 证 码: <INPUT size=5 name=CheckCode> 请输入<span style="MARGIN: 16px 0px 6px"><img src="GetCode.asp"></span><BR>
<BR><INPUT type=submit value=" 发 送 " name=submit1><BR><BR>
</form>
<P></P></DIV></td>
</tr>
</table>
<table width="750" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<!--#include file="foot.asp"-->
</body>
</html>
<%
sub ReSendPsw
if Trim(Request("CheckCode"))="" or isnull(Request("CheckCode")) then
session("Errmsg") = session("Errmsg")+" - 请输入附加码。<br>"
exit sub
elseif session("Num")="" then
session("Errmsg") = session("Errmsg")+" - 请不要重复提交,如需重新登陆请返回登陆页面。<br>"
exit sub
elseif Trim(Request("CheckCode"))<>session("Num") then
session("Errmsg") = session("Errmsg")+" - 你输入的附加码和系统产生的不符。<br>"
exit sub
end if
if Trim(Request("uname")) = "" or Trim(Request("email")) = "" then
session("Errmsg") = session("Errmsg")&" - 请输入用户名和注册时填写的电子邮箱。<br>"
exit sub
else
uname = checkStr(Request("uname"))
email = checkStr(Request("email"))
end if
Sql = "Select * from Users where UserName='"& uname &"'"
'on error resume next
Rs.open sql,conn,1,3
if Rs.eof and Rs.bof then
Rs.close
Set Rs = nothing
session("Errmsg") = session("Errmsg")+" - 您输入的用户名或电子邮箱不正确。<br>"
exit sub
else
if Trim(rs("Email"))<>email then
session("Errmsg") = session("Errmsg")+" - 您输入的用户名或电子邮箱不正确。<br>"
exit sub
else
'登录成功,重新发送一个新的密码到其邮箱里
'第一步,得到一个新的随机密码
dim num1
dim rndnum
Randomize
Do While Len(rndnum)<Cint(NewPass)
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
'第二步向其邮箱里发送此密码
STRSUBJECT="您在"&NetName&"的新密码"
STRCONTENT="尊敬的朋友您好!您的新密码为:"&rndnum&".欢迎您回到"&NetName&"."
EMAILADDRESS=email
call SendAction(STRSUBJECT,STRCONTENT,EMAILADDRESS)
'第三步,向数据库写入新的密码
rs("password")=md5(rndnum)
rs.update
'第四步,记录成功变量
rs.close
set rs=nothing
response.write "<script>alert('您的新密码已经发送到了您的邮箱里,请注意查收');location.href='usergetpass.asp'</script>"
end if
end if
end sub
Sub SendAction(STRSUBJECT,STRCONTENT,EMAILADDRESS)
Set msg = Server.CreateObject("JMail.Message")
'msg.silent = true
msg.Logging = true
msg.Charset = "gb2312"
msg.ContentType = "text/html"
msg.MailServerUserName = NetEmail '输入smtp服务器验证登陆名 (邮局中任何一个用户的Email地址)
msg.MailServerPassword = NetEmailPsw '输入smtp服务器验证密码 (用户Email帐号对应的密码)
msg.From = NetEmail '发件人Email
msg.FromName = NetName '发件人姓名
msg.AddRecipient EMAILADDRESS '收件人Email
msg.Subject = STRSUBJECT '信件主题
msg.Body = STRCONTENT '正文
msg.Send (NetPostOffice) 'smtp服务器地址(企业邮局地址)
msg.close
set msg = nothing
End Sub
%>
<%
Function ShowContent ()
sql="select GetPass from Notice"
set rs=conn.execute (sql)
if not rs.eof then
response.write rs(0)
rs.close
end if
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -