求救:密码修改问题!!! 我做了一个登陆和密码修改功能的界面,但密码不能修改,代码总是写不对,帮帮忙,谢谢! 原文件在 数据库名为: exam.mdb 字段与数据如下:
Userid UserName Pwd Department Rank Ifadmin 1 张东 1 儿科 主治医师 -1 2 李新 900 儿科 普通医生 0 3 于琦 1020 儿科 普通医生 0 4 李明 1022 骨科 主治医师 0 5 李佳宸 1023 骨科 普通医生 0
登陆代码如下:
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40"> <head>
<base target="_top"> <link rel="stylesheet" type="text/css" href="css.css"> </head> <body topmargin="0" leftmargin="0" bgcolor="#FFFFFF"> <form method="POST" action="checkusr.asp"> <table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="165"> <tr bgcolor="#F2AF4A"> <td colspan="2" height="30"> <p align="center"> <img border="0" src="images/login.jpg" width="120" height="30"></td> </tr> <%if request("temp")="error" then%> <tr> <td colspan="2" height="12"> <p align="center">用户名或者密码错误!</td> </tr> <%end if%> <%if request("temp")="nota" then%> <tr> <td colspan="2" height="12"> <p align="center">你不是系统管理员!</td> </tr> <%end if%> <tr> <td height="19"> <p align="right"> 学生证号:</td> <td height="19"><input type="text" name="userid" size="10" class="s01"></td> </tr> <tr> <td height="19"> <p align="right"> 密 码:</td> <td height="19"><input type="password" name="pwd" size="10" class="s01"></td> </tr> <tr> <td colspan="2" height="20"> <p align="center"><input type="checkbox" name="kind" value="A">系统管理员</td> </tr> <tr> <td colspan="2" height="21"> <p align="center"> <input border="0" value="登 录" name="I1" type="submit" class="s02"><input type="reset" value="重 置" name="B1" class="s02"></td> </tr> </table> </form> </body> </html>
核对代码如下:
<!--#include file="conn.inc" '连接数据库 --> <% userid=request("userid") pwd=request("pwd") kind=request("kind") '接收表单信息 sql="select * from cadre_info where userid="& userid & "and pwd="& pwd response.write sql set rs=conn.execute(sql) if rs.eof then '如果不存在对应的用户密码 response.redirect "loginleftframe.asp?temp=error" else '如果用户密码检验正确 userid=rs("userid") username=rs("username") department=rs("department") rank=rs("rank") ifadmin=rs("ifadmin") response.cookies("downloadok")="" rs.close end if if kind="A" then '如果用户想要以管理员身份进入 if ifadmin=true then '如果用户拥有管理员权限 Response.Cookies("userid")=userid Response.Cookies("username")=username Response.Cookies("pwd")=pwd Response.Cookies("rank")=rank Response.Cookies("department")=department Response.Cookies("ifadmin")=ifadmin response.redirect "adminleftframe.asp" else '如果用户没有管理员权限 response.redirect "loginleftframe.asp?temp=nota" end if else '如果用户想要以普通考生身份进入 Response.Cookies("userid")=userid Response.Cookies("username")=username Response.Cookies("pwd")=pwd Response.Cookies("department")=department Response.Cookies("POST")=post Response.Cookies("rank")=rank response.redirect "leftframe.asp" end if %>
分为普通用户和管理员登陆:
登陆后密码修改代码如下:
<!--#include file="conn.inc"--> <% if request("newpwd")<>"" then sql="select * from cadre_info where userid="& request.cookies("userid") set rs=server.createobject("adodb.recordset") rs.open sql,conn,3,2 if rs("pwd")=request("oldpwd.value=") then rs("pwd")=request("newpwd") rs.update response.redirect "editpwd.asp?error=ok" else response.redirect "editpwd.asp?error=wrong" end if end if %> <html>
<head> <meta http-equiv="Content-Language" content="zh-cn"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title></title> <base target="_self"> <script language="javascript"> function submitit() { var myform=document.editpwd; if (myform.oldpwd.value=="") { alert("原有密码不能为空!"); return false; } else { if (myform.newpwd.value=="") { alert("新密码不能为空不能为空!"); return false; } else { if (myform.confirmpwd.value=="") { alert("验证密码不能为空!"); return false; } else { if (myform.newpwd.value!=myform.confirmpwd.value) { alert("新设密码和验证密码不相符!"); return false; } else { return true; } } } } } </script> <link rel="stylesheet" type="text/css" href="css.css"> </head>
<body topmargin="0" leftmargin="0" style="background-color: #F1F1F1">
<form method="POST" name="editpwd" action="editpwd.asp" onsubmit="return submitit();"> <div align="center"> <center> <table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1" cellspacing="0"> <tr> <% if request("error")="" then %> <td colspan="2" height="20"><font color="#FF0000">建议密码最好在6位以上</font></td> <% else if request("error")="ok" then %> <td colspan="2" height="20"><font color="#FF0000">成功修改密码!</font></td> <% else %> <td colspan="2" height="20"><font color="#FF0000">旧密码输入错误!</font></td> <% end if end if %> </tr> <tr> <td>原有密码:</td> <td> <input type="password" name="oldpwd" size="8" onblur="this.className='s01'" onfocus="this.className='inputedit';this.select()" class="s01"></td> </tr> <tr> <td>新设密码:</td> <td></font> <input type="password" name="newpwd" size="8" onblur="this.className='s01'" onfocus="this.className='inputedit';this.select()" class="s01"></td> </tr> <tr> <td>验证密码:</td> <td> <input type="password" name="confirmpwd" size="8" onblur="this.className='s01'" onfocus="this.className='inputedit';this.select()" class="s01"></td> </tr> <tr> <td colspan="2"> <p align="center"> <input border="0" value="保 存" name="I1" type="submit" class="s02"></td> </tr> </table> </center> </div> </form>
</body>
</html>
系统提示:旧密码输入错误!
请问怎么修改?
谢谢!!!