php-login choose page after login

285 views Asked by At

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");
}
3

There are 3 answers

5
user3173104 On BEST ANSWER

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");
}

}
2
Ahmad MOUSSA On

Well, try to create a main page (main.php), in this page write the code of choosing a page, its easy !!

if ($login->isUserLoggedIn() == true) {
include("views/main.php");
}
2
user3806613 On

You could store your pages names/links in mysql database first and then get the pages links/names from the mysql database in an array and put it right after your code which would excute after the users are logged in. like so:

if ($login->isUserLoggedIn() == true) {
///Your array of pages here ///

EDIT:

Based on your comment, you can do this:

if ($login->isUserLoggedIn() == false) {
header(location someotherpage.php)

You could put that code in the blue.php, green.php etc etc

Second edit:

I hope i understand it correctly and if so, then you can use something like this:

if ($login->isUserLoggedIn() == false) {
echo "access denied";

you could even populate your page names and links in a drop down menu fashion so the users can select one and go to that page.