by Zahid (7 Submissions)
Category: Miscellaneous
Compatability: VB Script
Difficulty: Unknown Difficulty
Originally Published: Wed 5th April 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Sample ASP code for allowing a user to modify their password.
<%option explicit%>
<%
dim item
dim NewPassWord
dim OldPassWord
dim Email
dim ConfirmPassWord
dim SetPassWord
dim PassWord
dim oRs
dim Connection
dim vSql
dim Updated
dim strConn
Updated=False
for each item in Request.Form
if item="e_mail" then
Email=Request.Form(Item)
end if
if item="OldPassWord" then
OldPassWord=Request.Form(Item)
end if
if item="NewPassWord" then
NewPassWord=Request.Form(Item)
end if
if item="ConfirmPassWord" then
ConfirmPassWord=Request.Form(Item)
end if
next
if NewPassWord<>ConfirmPassWord then
Response.Redirect "ChangePassWord.asp"
end if
set connection=Server.CreateObject("AdoDB.Connection")
Connection.Open "DSN=DbsName;uid=Admin;pwd="
set oRS=Server.CreateObject("AdoDB.RecordSet")
vSql = "SELECT Email,Passwd from Account" & _
" WHERE Email='" & Email & "'"
Connection.BeginTrans
oRs.Open vsql,connection, adOpenDynamic ,adLockOptimistic
If oRs.EOF <> True Then
If oRs("PassWd") = OldPassWord Then
oRs("PassWd") = NewPassWord
oRs.Update
Updated=True
End If
End If
oRs.Close
Connection.CommitTrans
set oRs=Nothing
Connection.Close
Set Connection=nothing
%>