Gossamer Forum
Home : General : Databases and SQL :

password change

Quote Reply
password change
<form action="change.asp">

old password <input type="password" name="oldpassword" >

new password <input type="password" name="password" >

retype password <input type="password" name="repassword" >

</form>






change.asp

dim p1,p2,p3

p1=request.form("password") p2=request.form("repassword")

if p1 <> p2 then

blah blah.....






I would like to know how to code my input oldpassword = to database before checking p1 = p2 ??

As i am making a normal changing of password

Thanks..

Smile
Quote Reply
Re: [gnehs] password change In reply to
Again, you should pick up an SQL book to help you with basic SQL statements.

Code:
p3 = request.form("oldpassword")

Code:
SELECT password
FROM usertable
WHERE (password = 'p3')

Depending on what database you are using, you should use UCASE or UPPER or BINARY to check to make sure that whatever case is typed in, it will be converted to upper case and match the upper case value of the password field in your user table.
========================================
Buh Bye!

Cheers,
Me

Last edited by:

Stealth: Aug 11, 2003, 11:32 AM
Quote Reply
Re: [Stealth] password change In reply to
well i tried but i can't sychronize them...

i dont know how to sychronize it pls help Thanks!

Code:
<% dim bcheck, ps, ps2 ps = request.form("ps")
ps2 = request.form("ps2")
ps3 = request.form("ps3")
%> <%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("Train.mdb"))

if Request.form("Staffpass")="" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT Staffpass FROM Login WHERE Staffid='" & session("userid2") &"'" ,conn
%>
<form method="post" action="psword.asp">


<table>
<%for each x in rs.Fields%>
<tr>
<td><input type="hidden" value="<%=x.name%>"></td>

<td><input type="hidden" name="<%=x.name%>" value="<%=x.value%>"></td>

<%next%>

</tr>


</table>

<table border="0">

<tr><td>New Password input type="password" name="ps"></td></tr>
<tr><td>Retype New Password :&nbsp;<input type="password" name="ps2"></td></tr>
<tr><td>Old Password :&nbsp;<input type="password" name="ps3"></td></tr>
</table>
<br /><br />

<input type="submit" value="Change Password" style="background-color: #dddddd; background-repeat: repeat; background-attachment: scroll; width: 100; height: 20; border: 2px solid black; background-position: 0% 50%; font-family: verdana; font-size: 9">

<br><br><font face="verdana" size="1"><a href="../test/staff.asp" STYLE='text-decoration: none'>Back</a></font>


</form>


<%
else


sql="UPDATE Login SET "
sql=sql & "Staffpass ='" & Request.Form("ps2") & "' "
sql=sql & " WHERE Staffid='" & session("userid2") &"'"


on error resume next

conn.Execute sql


set rs=Server.CreateObject("ADODB.Recordset")
if "SELECT * FROM Login WHERE Staffpass='" & request.form("ps3") &"'" then

if ps <> ps2 then


bcheck=false
response.write("<br><br><br><table border='1' width='500'><tr><td>")
response.write(" <center><br>Wrong Password! <br><br><b>Password</b> and <B>Retype Password</B> must be the same. <br><br>")

response.write("<font face='verdana' size='1'><a href='psword.asp' STYLE='text-decoration: none'>Back</a></font>")
response.write("<br><br></center></td></tr></table><br>")

'response.redirect("error.html")'
' the redirect means that when wrong password is type,'
'everything will stop here and go to another link.'
'Need to do this because for this kind of loop, when it detected error,'
'it will stop there and print out that error msg, so do a redirect to another'
'link is another way to check this kind of error.'

else
bcheck=true

if ps = ps2 then


response.write("<br>")
response.write("<br>")
response.write("<br><table border='1' width='500'><td>")
response.write("<center><font color='white'><br>Password Changed<br></font></center>")
response.write("<br><center><font face='verdana' size='1'><a href='login.asp' STYLE='text-decoration: none'>ReLogin</a></font>")
response.write("</center><br>")
response.write("</td></table>")

end if
end if
end if
end if
conn.close

%>