请各位帮我看看代码哪里有问题,关于修改密码

rollin5460 2008-12-16 11:02:25
我加上这段代码,如果点修改密码进入的时候就一直是wrong current password 这个提示,并且进不了修改密码页面。请大家帮我看看,到底是哪里出问题了。


<%

pwd1=trim(request("pwd1"))
pwd2=trim(request("pwd2"))
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from user_info where name='"&session("username")&"' "
rs.open sql,conn,1,3

if rs("password")<>pwd1 then
response.write "<script language='javascript'>"
response.write "alert('Wrong current password!');window.location.href='changepw.asp';"
response.write "</script>"
response.end
else
rs("password")=pwd2
rs.update
response.write "<script language='javascript'>"
response.write "alert('Change password success,please remember the new password!');window.location.href='home.asp';"
response.write " </script>"


rs.close
set rs=nothing
end if
%>
...全文
147 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
呵呵,谢谢大家的关注。结贴散分啦!
sy_binbin 2008-12-16
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 jxdz086465 的回复:]
把你提问得代码改成
if request("OK") <>"" then '加上是否提交数据得判断

pwd1=request("pwd1")
pwd2=request("pwd2")

set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from user_info where [name]='"&session("username")&"' "
rs.open sql,conn,1,3
response.write rs("password") & " <br>"
response.write pwd1
if rs("password") <>pwd1 then
response.wr…
[/Quote]

这样就差不多了!
layers2323 2008-12-16
  • 打赏
  • 举报
回复
你的程序执行逻辑顺序上有问题,多熟悉下asp的基础东西吧。
jxdz086465 2008-12-16
  • 打赏
  • 举报
回复
把你提问得代码改成
if request("OK") <>"" then '加上是否提交数据得判断

pwd1=request("pwd1")
pwd2=request("pwd2")

set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from user_info where [name]='"&session("username")&"' "
rs.open sql,conn,1,3
response.write rs("password") & " <br>"
response.write pwd1
if rs("password") <>pwd1 then
response.write " <script language='javascript'>"
response.write "alert('Wrong current password!');"
response.write " </script>"
response.end
else
rs("password")=pwd2
rs.update
response.write " <script language='javascript'>"
response.write "alert('Change password success,please remember the new password!');"
response.write " </script>"


rs.close
set rs=nothing
end if

end if
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
我放两个页面就没问题,不明白,我有的页面也是这样写的,没什么问题,为什么就这个页面有问题呢
layers2323 2008-12-16
  • 打赏
  • 举报
回复
response.write rs("password") & " <br>"
response.write pwd1


输出的内容是什么?
jxdz086465 2008-12-16
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- #include file="conn.asp" -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DCC Database System</title>
</head>
<script language="javascript">
function check(){
if(document.myform.pwd1.value=="")
{
document.myform.pwd1.focus();
alert("Please input the current password!");
return false;

}
if(document.myform.pwd2.value=="")
{
document.myform.pwd2.focus();
alert("Please input the new password!");
return false;

}
if(document.myform.pwd3.value=="")
{
document.myform.pwd3.focus();
alert("Please input the new password again!");
return false;

}

if(document.myform.pwd2.value!=document.myform.pwd3.value)
{
alert("You input two different passwords!");
return false;

}


}
</script>
<body >
<%
if request("OK")<>"" then

pwd1=request("pwd1")
pwd2=request("pwd2")

set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from user_info where [name]='"&session("username")&"' "
rs.open sql,conn,1,3
response.write rs("password") & " <br>"
response.write pwd1
if rs("password")<>pwd1 then
response.write "<script language='javascript'>"
response.write "alert('Wrong current password!');"
response.write "</script>"
response.end
else
rs("password")=pwd2
rs.update
response.write "<script language='javascript'>"
response.write "alert('Change password success,please remember the new password!');"
response.write " </script>"


rs.close
set rs=nothing
end if

end if
%>

<form id="myform" name="myform" method="post" action="" onSubmit="return check();">
<table width="970" border="0" cellspacing="0" cellpadding="0" align="center" height="269" >
<tr>
<td height="260" valign="bottom" bordercolor="#9966CC" background="images/top.jpg">
<table width="700" border="0" align="right" cellpadding="0" cellspacing="0" height="17">
<tr>
<td width="82" height="19" align="center" valign="middle"><b><a href="newdoc.asp">
New DOC</a></b></td>
<td width="104" height="19" align="center" valign="middle"><b>
<a href="editdoc.asp">Edit DOC</a></b></td>
<td width="103" height="19" align="center" valign="middle">
<b><a href="edittype.asp">Edit Type</a></b></td>
<td width="124" height="19" align="center" valign="middle">
<a href="editproject.asp"><b>Edit Project</b></a></td>
<td width="81" height="19" align="center" valign="middle">
<a href="search.asp"><b>Search</b></a></td>
<td width="81" height="19" align="center" valign="middle">
<a href="report.asp"><b>Report</b></a></td>
<td width="108" height="19" align="center" valign="middle"> </td>
<td width="16" height="19"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="9" align="center" valign="top" background="images/line.jpg">

<table border="0" width="96%" id="table1" height="215">
<tr>
<td height="211">
<table border="0" width="96%" id="table2" height="47">
<tr>
<td height="43" align="left">
<img border="0" src="images/ico05.gif" width="32" height="32">
<font size="4" color="#9999FF"><b>Change Password</b></font></td>
</tr>
<tr><td align="center">
<table width="90%" style="border-style: solid; border-width: 2px" bordercolor="#000000" height="162">
<tr>
<td bgcolor="#9AA7ED" align="left" height="25" colspan="2" >
<p align="center"><font size="4" color="#FFFFFF"><b>
<img border="0" src="images/res.gif" width="15" height="13"> Change Password</b></font></td>
</tr>
<tr>
<td bgcolor="#E7F0FA" align="right" height="36" >
<p align="right"><b>User Name:<font color="#FF0000"></font>
</b></td>
<td bgcolor="#E7F0FA" align="left" height="36" width="60%" >
<font size="3">
<input type="text" name="username" size="26" value="<%=session("username")%>" readonly></font></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="right" height="27" >
<p align="right"><b>
       Current password: </b>
</td>
<td bgcolor="#FFFFFF" align="left" height="27" >
<font size="3">
<input type="password" name="pwd1" size="26" value="" ><font color="#FF0000">*</font></font></td>
</tr>
<tr>
<td bgcolor="#E7F0FA" align="right" height="24" width="39%">
<b>New password: </b> </td>
<td bgcolor="#E7F0FA" align="left" height="24" >
<font size="3">
<input type="password" name="pwd2" size="26" value="" ><font color="#FF0000">*</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" height="35" width="39%">
<p align="right"><b> New password again: </b> </td>
<td align="left" height="35" >
<font size="3">
<input type="password" name="pwd3" size="26" value="" ><font color="#FF0000">*</font></font></td>
</tr>
<tr>
<td bgcolor="#9AA7ED" align="center" height="23" colspan="2" >



<p align="left">                            <input type="submit" value=" OK " name="OK" >    <input name="button" type="button" class="botton" onClick="Javascript:window.history.go(-1);" value=" Back " />   
<input type="reset" value="Cancel" name="cancel" ></td>
</tr>
</table>
</td>
</tr>


</table>
 </tr>


<tr>
<td height="51"><img src="images/copyright.jpg" width="990" height="51" ></td>
</tr>

</table>

</form>

</body>

</html>
jxdz086465 2008-12-16
  • 打赏
  • 举报
回复
这段程序前提要是在填写好表单提交的时候才用到

你可以把修改页面与程序页面做到两个页 这样就不会混乱了

要不然就再一个页面用参数判断

if rrequest("Submit")<>"" then

你上边那段程序

else

表单内容
end if
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 layers2323 的回复:]
老兄 不是进不了,你是一进去就跳转了,你把window.location注释掉不就完了么
[/Quote]

我已经删掉了,还是不行呀
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
整个页面代码



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- #include file="conn.asp" -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DCC Database System</title>
</head>
<script language="javascript">
function check(){
if(document.myform.pwd1.value=="")
{
document.myform.pwd1.focus();
alert("Please input the current password!");
return false;

}
if(document.myform.pwd2.value=="")
{
document.myform.pwd2.focus();
alert("Please input the new password!");
return false;

}
if(document.myform.pwd3.value=="")
{
document.myform.pwd3.focus();
alert("Please input the new password again!");
return false;

}

if(document.myform.pwd2.value!=document.myform.pwd3.value)
{
alert("You input two different passwords!");
return false;

}


}
</script>
<body >
<%

pwd1=request("pwd1")
pwd2=request("pwd2")

set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from user_info where [name]='"&session("username")&"' "
rs.open sql,conn,1,3
response.write rs("password") & " <br>"
response.write pwd1
if rs("password")<>pwd1 then
response.write "<script language='javascript'>"
response.write "alert('Wrong current password!');"
response.write "</script>"
response.end
else
rs("password")=pwd2
rs.update
response.write "<script language='javascript'>"
response.write "alert('Change password success,please remember the new password!');"
response.write " </script>"


rs.close
set rs=nothing
end if
%>

<form id="myform" name="myform" method="post" action="" onSubmit="return check();">
<table width="970" border="0" cellspacing="0" cellpadding="0" align="center" height="269" >
<tr>
<td height="260" valign="bottom" bordercolor="#9966CC" background="images/top.jpg">
<table width="700" border="0" align="right" cellpadding="0" cellspacing="0" height="17">
<tr>
<td width="82" height="19" align="center" valign="middle"><b><a href="newdoc.asp">
New DOC</a></b></td>
<td width="104" height="19" align="center" valign="middle"><b>
<a href="editdoc.asp">Edit DOC</a></b></td>
<td width="103" height="19" align="center" valign="middle">
<b><a href="edittype.asp">Edit Type</a></b></td>
<td width="124" height="19" align="center" valign="middle">
<a href="editproject.asp"><b>Edit Project</b></a></td>
<td width="81" height="19" align="center" valign="middle">
<a href="search.asp"><b>Search</b></a></td>
<td width="81" height="19" align="center" valign="middle">
<a href="report.asp"><b>Report</b></a></td>
<td width="108" height="19" align="center" valign="middle"> </td>
<td width="16" height="19"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="9" align="center" valign="top" background="images/line.jpg">

<table border="0" width="96%" id="table1" height="215">
<tr>
<td height="211">
<table border="0" width="96%" id="table2" height="47">
<tr>
<td height="43" align="left">
<img border="0" src="images/ico05.gif" width="32" height="32">
<font size="4" color="#9999FF"><b>Change Password</b></font></td>
</tr>
<tr><td align="center">
<table width="90%" style="border-style: solid; border-width: 2px" bordercolor="#000000" height="162">
<tr>
<td bgcolor="#9AA7ED" align="left" height="25" colspan="2" >
<p align="center"><font size="4" color="#FFFFFF"><b>
<img border="0" src="images/res.gif" width="15" height="13"> Change Password</b></font></td>
</tr>
<tr>
<td bgcolor="#E7F0FA" align="right" height="36" >
<p align="right"><b>User Name:<font color="#FF0000"></font>
</b></td>
<td bgcolor="#E7F0FA" align="left" height="36" width="60%" >
<font size="3">
<input type="text" name="username" size="26" value="<%=session("username")%>" readonly></font></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="right" height="27" >
<p align="right"><b>
       Current password: </b>
</td>
<td bgcolor="#FFFFFF" align="left" height="27" >
<font size="3">
<input type="password" name="pwd1" size="26" value="" ><font color="#FF0000">*</font></font></td>
</tr>
<tr>
<td bgcolor="#E7F0FA" align="right" height="24" width="39%">
<b>New password: </b> </td>
<td bgcolor="#E7F0FA" align="left" height="24" >
<font size="3">
<input type="password" name="pwd2" size="26" value="" ><font color="#FF0000">*</font></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" height="35" width="39%">
<p align="right"><b> New password again: </b> </td>
<td align="left" height="35" >
<font size="3">
<input type="password" name="pwd3" size="26" value="" ><font color="#FF0000">*</font></font></td>
</tr>
<tr>
<td bgcolor="#9AA7ED" align="center" height="23" colspan="2" >



<p align="left">                            <input type="submit" value=" OK " name="OK" >    <input name="button" type="button" class="botton" onClick="Javascript:window.history.go(-1);" value=" Back " />   
<input type="reset" value="Cancel" name="cancel" ></td>
</tr>
</table>
</td>
</tr>


</table>
 </tr>


<tr>
<td height="51"><img src="images/copyright.jpg" width="990" height="51" ></td>
</tr>

</table>

</form>

</body>

</html>
layers2323 2008-12-16
  • 打赏
  • 举报
回复
老兄 不是进不了,你是一进去就跳转了,你把window.location注释掉不就完了么
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
你在if上面加上
response.write rs("password") & " <br>"
response.write pwd1


输出两个密码,但是我只得到数据库的密码,因为没有进到修改密码页面,没有进行操作,而一直弹出错误的密码提示。
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
数据库时的密码能够得到,但是我无法进到页面呀。
layers2323 2008-12-16
  • 打赏
  • 举报
回复
把 window.location.href='changepw.asp' 先注释掉
layers2323 2008-12-16
  • 打赏
  • 举报
回复
你在if上面加上
response.write rs("password") & "<br>"
response.write pwd1
sy_binbin 2008-12-16
  • 打赏
  • 举报
回复
代码贴完整一些
rollin5460 2008-12-16
  • 打赏
  • 举报
回复
我没有经过MD5加密呀。我一进入修改密码页面就出来wrong current password弹出框,并且一直弹出来,没有进入页面。
layers2323 2008-12-16
  • 打赏
  • 举报
回复
那就是rs("password")和pwd1不一样咯。输出来看看。
sy_binbin 2008-12-16
  • 打赏
  • 举报
回复
sql="select * from user_info where [name]='"&session("username")&"' "

你把数据库内的密码输出一下,看看密码是不是MD5加密了!??

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧