jobs1109 Posted October 4, 2011 Share Posted October 4, 2011 Hi, I am having a bit of problem with my login/logout script. When user is logged in I want the script to show logout and if they are not login I want the script to show login. The problem is even when the user is logged in it says "you must be logged in Click here to login " here is the script Please help <?php session_start(); $_SESSION['username'] = $_POST['username']; if ($_SESSION['username']) echo "Welcome, ".$_SESSION['username']."!<br><a href='logout.php'>Logout</a>" ; else die("you must be logged in <a href='Login.php'>Click here to login</a>"); ?> what did I do wrong in this script ? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/248400-problem-with-login-logout/ Share on other sites More sharing options...
dougjohnson Posted October 4, 2011 Share Posted October 4, 2011 First, I'm assuming the script we are talking about is ONLY displayed once upon logging in. If it is used more than once you would need to POST the username to it each time. Or you would get the results you are talking about. Probably won't help? Quote Link to comment https://forums.phpfreaks.com/topic/248400-problem-with-login-logout/#findComment-1275615 Share on other sites More sharing options...
jobs1109 Posted October 4, 2011 Author Share Posted October 4, 2011 How do I modify it so that it can be displayed mutiple times and still show the correct login/logout option ? Quote Link to comment https://forums.phpfreaks.com/topic/248400-problem-with-login-logout/#findComment-1275729 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.