关于ASP修改密码的代码,错误在哪?

<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>无... <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>
</head>

<body>
<%

db="D.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
if request("action")="xiugai" then
dim yonghuming,yuanmima,xinmima,queren,sql,rs,strsql
yonghuming=cstr(request.form("yonghuming"))
yuanmima=cstr(request.form("yuanmima"))
xinmima=cstr(request.form("xinmima"))
queren=cstr(request.form("queren"))

'判断原来的用户名及密码是否正确。
set rs=Server.CreateObject("ADODB.Recordset")

strsql="select * from [user] where lower(uesr)='"&lcase(yonghuming)&"'"
rs.open strsql,conn,1,3
if rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
response.Write("<script>alert('不存在的用户名!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
response.end
end if

if trim(rs("pws"))<>yuanmima then
response.Write("<script>alert('原密码错误!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
response.end
end if

sql="update [user] set pws='"&cstr(request.form("xinmima"))&"'where uesr='"&cstr(request.form("yonghuming"))&"'"
rs.open sql,conn,1,3
conn.Execute(sql)

if xinmima<>queren then
response.Write("<script>alert('新密码和确认密码不一致!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
Response.End()
else

Response.Write("<script>alert('恭喜,密码修改成功!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
Response.End()
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
end if

%>
<form name="form1" method="post" action="editpwd.asp?action=xiugai">
<table width="190" border="1" align="center">
<tr>
<th width="86" height="30" scope="row"><div align="left" class="style1">用户名:</div></th>
<td width="88"><input name="yonghuming" type="text" size="8"></td>
</tr>
<tr>
<th height="21" scope="row"><div align="left" class="style1">原密码:</div></th>
<td><input name="yuanmima" type="password" size="8"></td>
</tr>
<tr>
<th height="21" scope="row"><div align="left" class="style1">新密码:</div></th>
<td><input name="xinmima" type="password" size="8"></td>
</tr>
<tr>
<th height="20" scope="row"><div align="left" class="style1">确认密码:</div></th>
<td><input name="queren" type="password" size="8"></td>
</tr>
<tr>
<th height="25" colspan="2" scope="row"><input name="xiugai" type="submit" id="xiugai" value="提交" onClick="submitit()">
<input type="reset" name="Submit2" value="重填">
<input name="按钮" type ="button" value ="返回登录页" onClick="location.href='biaozhun.asp'"></th>
</tr>
</table>
</form>
</body>
</html>
展开
 我来答
hnt8
推荐于2016-05-12 · TA获得超过107个赞
知道小有建树答主
回答量:700
采纳率:0%
帮助的人:328万
展开全部
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>
</head>

<body>
<%

db="D.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
if request("action")="xiugai" then
dim yonghuming,yuanmima,xinmima,queren,sql,rs,strsql
yonghuming=cstr(request.form("yonghuming"))
yuanmima=cstr(request.form("yuanmima"))
xinmima=cstr(request.form("xinmima"))
queren=cstr(request.form("queren"))

'判断原来的用户名及密码是否正确。
set rs=Server.CreateObject("ADODB.Recordset")

strsql="select * from [user] where lower(uesr)='"&lcase(yonghuming)&"'"
rs.open strsql,conn,1,3
if rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
response.Write("<script>alert('不存在的用户名!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
response.end
end if

if trim(rs("pws"))<>yuanmima then
response.Write("<script>alert('原密码错误!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
response.end
end if

if xinmima<>queren then
response.Write("<script>alert('新密码和确认密码不一致!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
Response.End()
end if

rs("pws=")=cstr(request.form("xinmima"))
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing

Response.Write("<script>alert('恭喜,密码修改成功!');location='"&request.ServerVariables("HTTP_REFERER")&"'</script>")
Response.End()

end if

%>
<form name="form1" method="post" action="editpwd.asp?action=xiugai">
<table width="190" border="1" align="center">
<tr>
<th width="86" height="30" scope="row"><div align="left" class="style1">用户名:</div></th>
<td width="88"><input name="yonghuming" type="text" size="8"></td>
</tr>
<tr>
<th height="21" scope="row"><div align="left" class="style1">原密码:</div></th>
<td><input name="yuanmima" type="password" size="8"></td>
</tr>
<tr>
<th height="21" scope="row"><div align="left" class="style1">新密码:</div></th>
<td><input name="xinmima" type="password" size="8"></td>
</tr>
<tr>
<th height="20" scope="row"><div align="left" class="style1">确认密码:</div></th>
<td><input name="queren" type="password" size="8"></td>
</tr>
<tr>
<th height="25" colspan="2" scope="row"><input name="xiugai" type="submit" id="xiugai" value="提交" onClick="submitit()">
<input type="reset" name="Submit2" value="重填">
<input name="按钮" type ="button" value ="返回登录页" onClick="location.href='biaozhun.asp'"></th>
</tr>
</table>
</form>
</body>
</html>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式