enemeth Posted April 12, 2007 Share Posted April 12, 2007 Hi there got this problem with the log out script, can someone tell me what i am doing wrong? <?php // This blurb starts the session for the users. session_start(); header("Cache-control: private"); // Fix for ie6 ?> <?php $msg = "Please Log In!"; ?> <?php if(!isset($_SESSION['username'])) { echo("<meta http-equiv='Refresh' content='0; URL=../login.php'/>"); echo ("<script langauge=\"javascript\">alert(\"".$msg."\");</script>"); } else { ?> <?php include("headermem.php"); ?> <center><font color=white> Are you sure you want to logout?</font></center><br> <center><a href=/index.php>Yes</a> | <?php unset($_SESSION['username']); ?> <a href=javascript:history.back()>No</a>"; <?php include 'footermem.php'; ?> <? } ?> i guess you guys can see it right off the bat ! but i guess i am blind but everytime you go to the page it logs you out no matter what your choice is Thank you Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/ Share on other sites More sharing options...
Trium918 Posted April 12, 2007 Share Posted April 12, 2007 Try this: <?php include("headermem.php"); ?> <center><font color=white> Are you sure you want to logout?</font></center><br> <center><a href=/logout.php>Yes</a> Create a new script and name it logout.php session_start(); $_SESSION['username']; // store to test if they *were* logged i if (!empty($_SESSION['usename'])) { if (isset($_SESSION['username'])) { unset($_SESSION['username']); session_destroy(); echo "Logged out.<br>"; } else { // they were logged in and could not be logged out echo "Could not log you out.<br>"; } } else { // if they weren't logged in but came to this page somehow echo "You were not logged in, and so have not been logged out.<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/#findComment-227857 Share on other sites More sharing options...
enemeth Posted April 12, 2007 Author Share Posted April 12, 2007 i got the error : Fatal error: Call to undefined function: do_html_header() in /home/www/thetruthdiscovered.com/members/logoutphp.php on line 5 when i did all that Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/#findComment-227911 Share on other sites More sharing options...
only one Posted April 12, 2007 Share Posted April 12, 2007 <?php // This blurb starts the session for the users. session_start(); header("Cache-control: private"); // Fix for ie6 ?> <?php $msg = "Please Log In!"; ?> <?php if($_SESSION['username']==NULL) { header("location: ../login.php"); echo ("<script langauge=\"javascript\">alert(\"".$msg."\");</script>"); } else { include("headermem.php"); ?> <center><font color=white> Are you sure you want to logout?</font></center><br> <center><a href=/index.php>Yes</a> | <?php unset($_SESSION['username']); ?> <a href=javascript:history.back()>No</a>"; <?php include 'footermem.php'; } ?> try that edit: if you want to make a logout page array $_SESSION['username'] Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/#findComment-227914 Share on other sites More sharing options...
enemeth Posted April 12, 2007 Author Share Posted April 12, 2007 ok i tried that one 'Only one' and it does the same thing , no mater what i do when i go to the logout page it logs me out even if i click no, or even just navigate to another link off that page Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/#findComment-227932 Share on other sites More sharing options...
enemeth Posted April 12, 2007 Author Share Posted April 12, 2007 Ok guys, i cant figure it out i have been playing with this code for a while now , cant seem to get it to work can someone help me get it to do this : log out button get clicked , goes to a page that will give you the choice , yes or no to log out or not to log out if the user hits yes he is notified that he is now logged out , and then redirected to the index.php page of the site ! thanks a million Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/#findComment-228020 Share on other sites More sharing options...
only one Posted April 13, 2007 Share Posted April 13, 2007 can i see the code to headermem.php? maybe youve got the problem in there Quote Link to comment https://forums.phpfreaks.com/topic/46753-log-out-problem/#findComment-228393 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.