Pages

Friday, 4 May 2012

Step 15: Creating the changepassword.php file

Step 15: Creating the changepassword.php file
On this page the user can change his password, ofcouse he has to be logged in first. He will also have to enter his old password.

file: changepassword.php

<?php
 
require_once "header.php";
 if (isLoggedIn() == true)
{
 
        if (isset($_POST['change']))
        {
 
                if (changePassword($_POST['username'], $_POST['oldpassword'], $_POST['password'],
                        $_POST['password2']))
                {
                        echo "Your password has been changed ! <br /> <a href='./index.php'>Return to homepage</a>";
 
                } else
                {
                        echo "Password change failed! Please try again.";
                        show_changepassword_form();
                }
 
        } else
        {
                show_changepassword_form();
        }
 } else {
        // user is not loggedin
        show_loginform();
}
 
require_once "footer.php";
 ?>

No comments:

Post a Comment

Thank you for your valuable comment