dad00 Posted February 28, 2009 Share Posted February 28, 2009 if(isset($_SESSION['logged'])){ if(isset($_POST['logout'])){ session_destroy(); echo"<meta http-equiv='refresh' content='1' url='index.php'"; } ?> logged in <form> <input type='button' name='logout' value='logout'></form> when i press the logout button nothing happens.. Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 try <form method="post" action="<?="$PHP_SELF";?>"> <input type='submit' name='logout' value='logout'> </form> sorry just changed it again Quote Link to comment Share on other sites More sharing options...
dad00 Posted February 28, 2009 Author Share Posted February 28, 2009 omg i forgot about that bit Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 does it work? Quote Link to comment Share on other sites More sharing options...
dad00 Posted February 28, 2009 Author Share Posted February 28, 2009 no it dosent Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 please post your entire script i see you have a php ending ?> but no start <? ?? Quote Link to comment Share on other sites More sharing options...
dad00 Posted February 28, 2009 Author Share Posted February 28, 2009 im not stupid i have put <?php at the beggining Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 you have two { { if(isset($_SESSION['logged'])){ // number one here. if(isset($_POST['logout'])){ // number two here. echo"<meta http-equiv='refresh' content='1' url='index.php'"; } // only one here ?> but only one } in what yoiu posted?? Quote Link to comment Share on other sites More sharing options...
dad00 Posted February 28, 2009 Author Share Posted February 28, 2009 after the php ends and the form appears that php appears again and then it gets closed and the rest of the code continues Quote Link to comment Share on other sites More sharing options...
DamienRoche Posted February 28, 2009 Share Posted February 28, 2009 just to be sure, do this: PUT AT TOP OF PAGE. $a = $_GET['a']; if($a == "logout"){ session_destroy(); header("location:index.php"); } LINK FOR HTML: <a href="?a=logout">logout</a> Make sure the sesion is being destroyed in your code. If so, then it is the actual meta refresh. If you put the above right at the top of your page, there is no need to refresh. Hope that helps. Quote Link to comment Share on other sites More sharing options...
daveoffy Posted February 28, 2009 Share Posted February 28, 2009 You can do this also, this is how I did my logout when I used sessions unset($_SESSION['username']); Quote Link to comment Share on other sites More sharing options...
dad00 Posted February 28, 2009 Author Share Posted February 28, 2009 works perfectly ty 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.