mirchi, create a form asking the user to enter their old password, their new password, and a confirmation of new password. Then run a <cfquery> that updates the dB where the username is equal to either the session var, form.username or url.username.
An example might be like this:
<cfquery name="updatepwd" datasource="someDSN">
UPDATE password
FROM table1
WHERE username = '#url.username#'
</cfquery>
This updates the password fild in the table1 table. Its better create a session variable, more safer.
Hope this helps.
____________________________________
Just Imagine.
don't forget to validate the passwords.
<!--- set Error message --->
<cfset errorMsg = "">
<!--- get old password --->
<cfquery name = "qGetOldPassword" datasource = "myDSN">
SELECT password FROM usersTable WHERE userName = "session.userName"
</cfquery>
<!--- check old passwords --->
<cfif qGetOldPassword.password neq form.password>
<cfset errorMsg = "Your old password did not match your current password<br>">
</cfif>
<!--- check to make sure the new passwords matched --->
<cfif form.password neq form.validatePassword>
<cfset errorMsg = errorMsg & "Your new passwords did not match<br>">
</cfif>
<!--- make update if no errors were found --->
<cfif errorMsg eq "">
<cfquery datasource = "myDSN">
UPDATE usersTable SET password = '#form.password#'
</cfquery>
</cfif>
this is easiest done if the page with the form submits to itsself. that way you don't have to worry about passing "errorMsg" back to the form page to present the user with the error...in my opinion anyway.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.