Table of Contents
It is important to have a forgot password system with login panel .
Using this any user can reset his/her password without any difficulties .
In this PHP tutorial ,we will be creating forgot password system. Forgot Password Recovery in PHP and MySQL Login system
Our previous tutorial of PHP Registration and login panel have a good startup for builing a user authentication system.Now we will ad option there for Password reset .If you haven't created login system with PHP, I recommend you to first visit our PHP login form tutorials.
Our previous tutorial of PHP Registration and login panel have a good startup for builing a user authentication system.Now we will ad option there for Password reset .If you haven't created login system with PHP, I recommend you to first visit our PHP login form tutorials.
Database Table Creation
We should have a user table inside our database to store user details Now just add a new field 'forgot_pass_identity' in this table . ALTER TABLE `users` ADD `forgot_pass_identity` VARCHAR(32) NOT NULL AFTER `contact`; Complete users table SQL will like the following.
Forgot password form
First create a form to ask user to reset there password .
Now Let's process the submitted form .
Below we are checking if user has submitted a valid email and also if it exists in our 'user' table
// if no errors
Below create message to send to user's email .Mention your own domain's email address instead of contact@domain.com and noprely@domain.com
So, we have successfully sent password to user's email. Now time to update encrypted password of the user record . Then set a variable to true we will use this to determine if the reset has been successful.
Below show any errors if there any.