h20boynz Posted April 27, 2010 Share Posted April 27, 2010 Hi there I'm banging my head against a wall and could really use some advice.... I am trying to include on a page one of two include files based on a simple criteria. <?php if (!isset($loginok)){ include $_SERVER['DOCUMENT_ROOT'] . '/phpscripts/login.home.php'; } else { include $_SERVER['DOCUMENT_ROOT'] . '/phpscripts/logout.home.php'; } ?> In another file I set $GLOBAL['loginok'] = 'Logged in'; (The other file checks for user name in DB etc) And after logging out I use unset($GLOBALS['loginok']); But no matter what state the $loginok value is in it will only show one of the include files. I've tried using $_SESSION variables that are set as well because I know they are se,t but they have the same result. The files login.home.php and logout.home.php are two little forms for display on the index.php page. I use seperate login.php page if a user navigates to a page that they are required to be logged in for. This all works well. I just want to show a logout button on the home page or a login box on the home page based on the users state...very fustrating Quote Link to comment Share on other sites More sharing options...
trq Posted April 27, 2010 Share Posted April 27, 2010 Where is $loginok defined within the above mentioned script? Quote Link to comment Share on other sites More sharing options...
h20boynz Posted April 27, 2010 Author Share Posted April 27, 2010 It's set in access.php if (databasecontainsuser($_POST['username'], $password)) { session_start(); $_SESSION['loggedin'] = TRUE; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $password; $GLOBALS['loginok'] = 'Logged in'; return TRUE; } else { session_start(); unset($_SESSION['loggedin']); unset($_SESSION['username']); unset($_SESSION['password']); $GLOBALS['loginerror'] = 'The specified user or password was incorrect.' . $email . $password; return FALSE; } $password = md5($_POST['password'] . 'xxxx'); } I've tried using isset on the $_SESSION variable above too but it has the same effect. Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted April 27, 2010 Share Posted April 27, 2010 And is access.php included into your original script? I've tried using isset on the $_SESSION variable above too but it has the same effect. Did you have session_start() before trying to use the $_SESSION array? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.