Home » Php » How to use forgot password in login page using php?

How to use forgot password in login page using php?

Posted by: admin October 26, 2017 Leave a comment

Questions:

log.php

$data =array();

my database fields for login

    $userEmail=$_POST['userEmail'];
    $userPass=$_POST['userPass'];

Validation for each of the fields

    $edata = array();
     if(empty($userEmail)){
        if(empty($edata)){
            $edata['errorcode']='Email Id field empty';
        }
    } 
Answers:

You can do like this :

  1. Get the email id on which user wants the link to reset the
    password.
  2. Once the user submits the email id, validate it and check that email id in your database whether any user with that email exits in your database.
  3. If the user is found, send the user an email with reset password
    link.
  4. Note that the reset password link should get expire once the user
    has used it. To achieve this you can keep a status column in your table which you can update once the user resets the password.

You can search for the sample examples to achieve this.