I too am struggling with getting the ASP page to change the password. I have tried everything that I can find in the forums, but what I end up with is and error message at the top of the password change box:
"UPDATE tblLogins SET [Password] = 'cat123' WHERE EMail = 'robegusn@central.btps.ca' "
I know that it is reading the "old" password because if I enter an incorrect password it gives the correct message - same goes if the "new" passwords don't match - I get an error message. The problem seems to be updating the database with the new password.
The contents of my db_connect.asp:
Set con = Server.CreateObject("ADODB.Connection") con.ConnectionTimeout = 10 con.CommandTimeout = 30 con.CursorLocation = 3 con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SpamFilter\Database\SpamFilter.mdb;Persist Security Info=False"
The contents of PasswordChange.asp:
<!--#include file="authenticate.asp"--> <% EmailTo = Session("EmailTo")
'Theoretically, this should never happen. If Len(EmailTo) < 1 Then Session("EmailTo") = Null Session.Abandon Response.Redirect "ListSpam.asp" End If
OldPassword = Request.Form("OldPassword")
If Len(OldPassword) Then NewPassword = Request.Form("NewPassword") ConfirmNewPassword = Request.Form("ConfirmNewPassword")
If Len(NewPassword) < 6 Then ErrorMessage = "New Password was too short!" ElseIf NewPassword <> ConfirmNewPassword Then ErrorMessage = "New Password and Confirm New Password did not match!" ElseIf OldPassword = NewPassword Then ErrorMessage = "New Password was the same as Old Password!" Else SQL = "SELECT Password " SQL = SQL & "FROM tblLogins " SQL = SQL & "WHERE EMail = '" & EmailTo & "'" Set rs = con.Execute(SQL)
If Not rs.EOF Then
If rs("Password") <> OldPassword Then ErrorMessage = "Old Password was incorrect!" Else SQL = "UPDATE tblLogins " SQL = SQL & "SET Password = '" & Replace(NewPassword,"'","''") & "' " SQL = SQL & "WHERE EMail = '" & Replace(EmailTo,"'","''") & "'" response.write SQL 'con.Execute SQL 'Response.Redirect "ListSpam.asp" End If
'This should also never happen. Else Session("EmailTo") = Null Session.Abandon Response.Redirect "ListSpam.asp" End If
End If
End If %> <html> <head> <title>Spam Filter - Password Change Form</title> </head> <body> <form method="post" name="PasswordChange"> <table align="center" border="1" cellpadding="1" cellspacing="1"> <% If Len(ErrorMessage) Then %> <tr> <td align="center" colspan="2"><span style="color:red"><%=ErrorMessage%></span></td> </tr> <% End If %> <tr> <td align="center" colspan="2"> <h2>Password Change For</h2> <%=EmailTo%> </td> </tr> <tr> <td align="right">Old Password:</td> <td><input type="password" size="15" name="OldPassword"></td> </tr> <tr> <td align="right">New Password:</td> <td><input type="password" size="15" name="NewPassword"></td> </tr> <tr> <td align="right">Confirm New Password:</td> <td><input type="password" size="15" name="ConfirmNewPassword"></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Change Password"> <input type="reset" value="Clear"> </td> </tr> </table> </form> </body> </html>
I have also explicitly given the IIS (anonymous) user rights to the database and the directory containing the database. Everything appears to be working except the change password feature.
I did make minor "cosmetic" changes to authenticate.asp, but since I can login I am assuming everything is OK.
If anyone can help with this - thanks in advance......
Robert
|