Translate

Friday, 4 May 2012

Step 6: Creating the login.php file

Step 6: Creating the login.php file
In this step we will make the actual login page, because we want to keep it readable we create some custom build functions that will handle the actual login. So basicly all this page will do is call the functions checkLogin(), show_loginform() and isLoggedIn()

<?phpif (!isLoggedIn())
{
        // user is not logged in.
        if (isset($_POST['cmdlogin']))
        {
                // retrieve the username and password sent from login form & check the login.
                if (checkLogin($_POST['username'], $_POST['password']))
                {
                        show_userbox();
                } else
                {
                        echo "Incorrect Login information !";
                        show_loginform();
                }
        } else
        {
                // User is not logged in and has not pressed the login button
                // so we show him the loginform
                show_loginform();
        }
 } else
{
        // The user is already loggedin, so we show the userbox.
        show_userbox();
}
?>

No comments: