Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Password

Status
Not open for further replies.

mirchi

Technical User
Feb 27, 2002
6
CA
I'm a new user to cold fusion and trying to make a cfm page to change old password to a new password and to confirm new password. Any help?
 
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=&quot;updatepwd&quot; datasource=&quot;someDSN&quot;>
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 = &quot;&quot;>
<!--- get old password --->
<cfquery name = &quot;qGetOldPassword&quot; datasource = &quot;myDSN&quot;>
SELECT password FROM usersTable WHERE userName = &quot;session.userName&quot;
</cfquery>
<!--- check old passwords --->
<cfif qGetOldPassword.password neq form.password>
<cfset errorMsg = &quot;Your old password did not match your current password<br>&quot;>
</cfif>
<!--- check to make sure the new passwords matched --->
<cfif form.password neq form.validatePassword>
<cfset errorMsg = errorMsg & &quot;Your new passwords did not match<br>&quot;>
</cfif>
<!--- make update if no errors were found --->
<cfif errorMsg eq &quot;&quot;>
<cfquery datasource = &quot;myDSN&quot;>
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 &quot;errorMsg&quot; back to the form page to present the user with the error...in my opinion anyway.

thereptilian120x120.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top