Search code examples
phpauthenticationlogin-script

php-login choose page after login


I am using the minimal version of php-login from: http://www.php-login.net/ on Windows 7. When the user logs in, the login is verified and the response from the verification is True or False. The response is returned to index.php which has this code

if ($login->isUserLoggedIn() == true) {
include("views/logged_in.php");

I would like to give the user an opportunity to choose which page they go to after logging in but that page can only be accessible when the user is logged in. Any ideas? Let me know if you need more information or if what I am trying to do isn't clear. Thanks

======= UPDATED BELOW ========================= I modified the code below so that if the user login validation returns true, the user is directed to a page that has these two links <a href="views/logged_in_green.php">Green</a> <a href="views/logged_in_blue.php">Blue</a> when the user clicks a link the user gets an Access Forbidden error message.

if ($login->isUserLoggedIn() == true) {
    include("views/choose-pages.htm");
} else {
    include("views/not_logged_in.php");
}

Solution

  • You can modify not_logged_in.php and have 2 submit buttons like Google, normal "Google search" and "I'm feeling luckey".

     <input type="submit" name="login" value="Log in green" />
     <input type="submit" name="login" value="Log in blue" />
    

    then modify index.php

    if ($login->isUserLoggedIn() == true) {
    
    if ($_POST["login"] == "Log in green") {
    include("green.php");
    } else {
    include("blue.php");
    }
    
    }