大家帮我看一下这段“修改密码”的代码

xhy19851 2009-08-15 05:43:08
大家帮我看一下这段“修改密码”的代码;

[size=10px][color=#0000FF][pre]
<%@language=vbscript%>
<!--#include file="conn.asp"-->
<%
If session("id")="" Then
response.redirect "Index.asp"
End If

lid=request("id")
username=request.form("username")
oldpass=request.form("oldpass")
newpass=request.form("newpass")
comfirmpass=request.form("comfirmpass")

If username<>"" And newpass=comfirmpass Then
sql="select * from userinfo where id="&cint("lid")
Set rs=server.CreateObject("adodb.recordset")
rs.open sql,strconn,3,2
If Not rs.eof Then
If oldpass=rs("密码") Then
rs("密码")=newpass
rs.update
response.redirect"ok3.asp"

Else
response.write("<script language=javascript>alert('密码不正确!请重新输入!');javascript.history.back(-1);</script>")
response.End
End If
End If
End If
%>
<HTML>
<HEAD>
<TITLE> editpass.asp </TITLE>
<script language=javascript>
function check()
{
if(document.input.username.value=="")
{
window.alert("请输入用户名")
return false
}
if(document.input.newpass.value!=document.input.comfirmpass.value)
{
window.alert("两次输入不相同!")
return false
}
return true
}
</script>
</HEAD>

<BODY>
<style>
body{font-size:9pt}
tr{font-size:9pt}
td{font-size:9pt}
input{font-size:9pt}
selet{font-size:9pt}
textarea{font-size:9pt}
</style>

<p align=center><font color=0000ff size=4><b>修改密码<b></font></p>
<form method=post action="" name=input onsubmit="return check()">
<div >
<center>
<table border=0 cellpadding=0 cellspacing=1 width=60%>
<tr>
<td width=35% align=center>账    号: </td>
<td width=65% ><input type=text name=username size=27 maxlength=30></td>
</tr>
<tr>
<td width=35% align=center>原始密码:</td>
<td width=65% ><input type=password name=oldpass size=30 maxlength=30></td>
</tr>
<tr>
<td width=35% align=center>新设密码:</td>
<td width=65% ><input type=password name=newpass size=30 maxlength=30></td>
</tr>
<tr>
<td width=35% align=center>确认密码:</td>
<td width=65% ><input type=password name=comfirmpass size=30 maxlength=30></td>
</tr>

</table>
</center>
</div>
<p align=center>
<input type=submit value=提交 name=sub>  
<input type=reset value=重置 name=sub>
</p>
</form>

</BODY>
</HTML>
[/pre]
[size=10px][color=#0000FF]
<!--#include file="conn.asp"-->的内容:
<%
Dim conn,strconn
strconn="provider=sqloledb;data source=vpc1;initial catalog=Txl;user id=sa;password=5413851"
Set conn=server.CreateObject("adodb.connection")
conn.connectionstring=strconn
conn.open
%>

我想用上面这段代码与表单实现对 储存在SQL数据库中的密码进行修改,而且上面的代码也能成功执行,但死活不能将数据库中的密码更改。而且旧密码乱输也不报错。有没有高手帮帮我看到底出了什么问题。


...全文
74 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
xhy19851 2009-08-15
今天中午终于找到问题,所在,密码终于改动了。程序开关少了个记录集。现贴出解决后的代码:
<%@language=vbscript%>
<!--#include file="conn.asp"-->
<%
If session("id")="" Then
response.redirect "Index.asp"
End If
sql="select * from userinfo"
Set editrs=server.CreateObject("adodb.recordset")
editrs.open sql,strconn,1,1
If Not editrs.eof Then
username=request.form("username")
oldpass=request.form("oldpass")
newpass=request.form("newpass")
comfirmpass=request.form("comfirmpass")

If username<>"" And newpass=comfirmpass Then
sql="select * from userinfo where id="&session("id")&""
Set rs=server.CreateObject("adodb.recordset")
rs.open sql,strconn,3,2
If Not rs.eof Then
If oldpass=rs("密码") Then
rs("密码")=newpass
rs.update
response.redirect"ok3.asp"

Else
response.write("<script language=javascript>alert('密码不正确!请重新输入!');javascript:history.back(-1);</script>")
response.End
End If
End If
End If
End if
lrsql="select * from userinfo where id="&session("id")&""
Set lrrs=server.CreateObject("adodb.recordset")
lrrs.open lrsql,strconn,1,1
name=lrrs("娃名")
lrrs.close
Set lrrs=Nothing
%>
<HTML>
<HEAD>
<TITLE> editpass.asp </TITLE>
<script language=javascript>
function check()
{
if(document.input.username.value=="")
{
window.alert("请输入用户名")
return false
}
if(document.input.newpass.value!=document.input.comfirmpass.value)
{
window.alert("两次输入不相同!")
return false
}
return true
}
</script>
</HEAD>

<BODY>
<style>
body{font-size:9pt}
tr{font-size:9pt}
td{font-size:9pt}
input{font-size:9pt}
selet{font-size:9pt}
textarea{font-size:9pt}
</style>

<p align=center><font color=0000ff size=4><b>修改密码<b></font></p>
<form method=post action="" name=input onsubmit="return check()">
<div >
<center>
<table border=0 cellpadding=0 cellspacing=1 width=60%>
<tr>
<td width=35% align=center>账    号:</td>
<td width=65% ><%=name%>
<input name="username" type="hidden" id="username" value="name" size=27 maxlength=30></td>
</tr>
<tr>
<td width=35% align=center>原始密码:</td>
<td width=65% ><input type=password name=oldpass size=30 maxlength=30></td>
</tr>
<tr>
<td width=35% align=center>新设密码:</td>
<td width=65% ><input type=password name=newpass size=30 maxlength=30></td>
</tr>
<tr>
<td width=35% align=center>确认密码:</td>
<td width=65% ><input type=password name=comfirmpass size=30 maxlength=30></td>
</tr>

</table>
</center>
</div>
<p align=center>
<input type=submit value=提交 name=sub>  
<input type=reset value=重置 name=sub>
</p>
</form>

</BODY>
</HTML>
谢谢大家参与!
回复
oywkkai 2009-08-15
LZ照4楼的修改一下看看
回复
toury 2009-08-15
If username <>"" And newpass=comfirmpass Then
sql="select * from userinfo where id="&cint("lid")
Set rs=server.CreateObject("adodb.recordset")
rs.open sql,strconn,3,2
rs.open sql,conn,1,3
If Not rs.eof Then
If oldpass=rs("密码") Then
rs("密码")=newpass
rs.update
response.redirect"ok3.asp"

Else
response.write(" <script language=javascript>alert('密码不正确!请重新输入!');javascript.history.back(-1); </script>")
response.End
End If
回复
Dogfish 2009-08-15
把sql语句打印出来看看。
回复
xhy19851 2009-08-15
改成sql="select * from userinfo where id=" & lid,还是一样呀,输完本该转到ok.asp,它还是转到本身的页面。
回复
Dogfish 2009-08-15
sql="select * from userinfo where id=" & cint("lid")

黑体部分不对。

sql="select * from userinfo where id=" & lid
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告