| |||||||
This is a discussion on PHP User Registration System - Forgot Password within the PHP/MySQL section, part of the Programming category; Part I - User Registration System Setup Part II - Account Confirmation or Email Authentication Part III - Forgot Password ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| Part I - User Registration System Setup Part II - Account Confirmation or Email Authentication Part III - Forgot Password Alright, so after finishing with the previous two tutorials, you might be interested in providing your users with a password reset feature, in case they forgot their password and are unable to login. We are going to deal with this now. You'll find it really easy if you understood the previous tuts. You should have the same database structure as described in Part I. Go through the code carefully. 1. First, we'll create a form where user will enter his registered email address which will be verified and a link to reset his password would be sent. forgot.php This is the HTML part that goes in forgot.php to setup our form. Optionally you can also validate the input field just like we did in Part I. HTML Code: <form name="forgotform" method="post" action="forgotprocess.php"> <p> <input name="email" type="text" id="email" size="35"> </p> <p> <input type="submit" name="Submit" value="Send Password" onClick="alert('Email would be validated and instructions would be sent. Do not forget to check your BULK folder and mark it as NO SPAM.')"> <input name="ip" type="hidden" id="ip" value="<?php echo $_SERVER['REMOTE_ADDR'];?>" /> <input name="todaysdate" type="hidden" id="todaysdate" value="<?php echo date("F j, Y");?>" /> </p> </form> <script language="JavaScript" type="text/javascript"> //You should create the validator only after the definition of the HTML form var frmvalidator = new Validator("forgotform"); frmvalidator.addValidation("email","req","Please enter your Email Address !!"); frmvalidator.addValidation("email","email","Please enter a valid email address !!"); </script> forgotprocess.php PHP Code: a) You'll notice the email part written twice in the code. This will take care of whether the user is requesting password reset for the first time, or has requested earlier too. b) Replace mysite with your own site name. c) Create file forgot_invalidemail.php with simple text saying Invalid Email or email does not exist in our registered users group. d) Create file forgot_linkmailed.php with simple text saying Success: Password Reset link mailed. e) I have added a Bcc header in the email so you (the admin) gets a copy of the mail too. This can help you know how many people how often are forgetting their password lol. You may remove it if you want.
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#2
| ||||
| ||||
|
4. So the user got the email with a password reset link. Now when he follows the link, reset_password.php is executed which updates his password in the table with a random password, as well as emails him the new temporary password. reset_password.php PHP Code: a) Replace mysite with your own site name. b) Create file forgot_invalidlink.php with simple text saying, Invalid Link followed, or the account is already activated. c) Create file forgot_success.php with simple text saying, Password Successfully changed.
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#3
| ||||
| ||||
|
Nice job webwizzy The only issue I have found so far is that privacy.php was not a file we made in the first part. The privacy policy was just part of register.php. I just copied my policy from register.php and pasted it into a privacy.php file and it seems to works fine. Again....Good Job
__________________ Go placidly amid the noise and haste, and remember what peace there may be in silence The Desiderada |
![]() |
| Bookmarks |
| Tags |
| tutorial, user registration system |
| Thread Tools | |
| Display Modes | |
| |