Translate

Friday, 4 May 2012

Step 14: Creating the lostpassword.php file

Step 14: Creating the lostpassword.php file
When the user lost his password he can request a new temporary password. He has to enter his username and his password, if they are correct his password will be reset to a radom generated password and an email will be sent containing this new password, the user can use this password to login and change its password.

file: lostpassword.php

<?php
 
require_once "header.php";
 if (isset($_POST['lostpass'])){
 
        if (lostPassword($_POST['username'], $_POST['email'])){
 
                echo "Your password has been reset, an email containing your new password has been sent to your inbox.<br />
                <a href='./index.php'>Click here to return to the homepage.</a>
                ";
 
        }else {
 
                echo "Username or email was incorrect !";
                show_lostpassword_form();
 
        }
 } else {
        //user has not pressed the button
        show_lostpassword_form();
}
 
 require_once "footer.php";
?>

No comments: