关于ASP密码修改页面的问题!

来源:百度知道 编辑:UC知道 时间:2024/06/12 00:11:10
我的一个密码修改后台程序:
<%
dim sql
dim rs

%>

<%
dim pass
pass=session("PASSWORD1")
username=request("text1")
psw=request("text2")
newpsw=request("text3")
renewpsw=request("text4")
If username="" or psw="" or newpsw="" or renewpsw="" Then
response.write "<script>alert('请重新输入完整的信息!');history.back();</script>"
End If
If newpsw <> renewpsw Then
response.write "<script>alert('新密码与确认新密码不一致,请重新输入!');history.back();</script>"
End If
set conn=server.CreateObject("ADODB.connection")
conn.connectionstring="provider=microsoft.jet.OLEDB.4.0;" &_
"data source=" & server.MapPath("CC.mdb")
conn.open
set rs=server.CreateObjec

在set rs=server.CreateObject("adodb.recordset")
sql="update USERs set PASSWORD1 = '" &newpsw & "' where USERNAME='" & username&"'"
中间加上这样几句,并把sql语句换掉,如下:
exec="select * from users where password1='"&pws&"' and username='"&username&"'"
rs.open exec,conn,1,1
if rs.eof and rs.bof then
response.write "<script>alert('您输入的原密码错误,请返回!');history.back();</script>"
response.end
else
sql="update USERs set PASSWORD1 = '" &newpsw & "' where USERNAME='" & username& "'"
conn.execute sql
End If %>

<script language="vbscript">
alert("信息修改成功!!!!")
window.location.href = "psw.asp"
</script>

用此变量psw_old来接收旧的密码,selcet password1 from users where username= 接收来的帐号
然后用if做判断。一致就同意修改密码。不一致