KaFF Posted March 17, 2007 Share Posted March 17, 2007 Hi there, Ive created a logout button for my site, but i want a validation screen to pop up to say "Are you sure you want to logout" Is there anyway of doing this? Please help Cheers Kaff Quote Link to comment Share on other sites More sharing options...
papaface Posted March 17, 2007 Share Posted March 17, 2007 if (isset($_POST['submit'])) { if (isset($_POST['yes'])) { //logout code yes } if (isset($_POST['no'])) { //logout code no } } else { //yes/no form } Quote Link to comment Share on other sites More sharing options...
marcus Posted March 17, 2007 Share Posted March 17, 2007 You could do javascript... <script language="JavaScript"> function confirmLogout() { var agree=confirm("Are you sure you want to log out?"); if (agree) return true ; else return false ; } </script> then for a link <a href="logout.php" onClick="return confirmLogout()">logout</a> Quote Link to comment Share on other sites More sharing options...
KaFF Posted March 19, 2007 Author Share Posted March 19, 2007 I tried using the javascript code as i currently have a href logout link on my pages but when i used the code in my logout.php it returned a blank page and didnt give the option of saying are you sure you want to logout. I am using session variables at the top of my pages and the logout page currently looks like this <?php session_start(); session_destroy(); header("location:login.php"); exit(); ?> If you could tell me where i am going wrong i would greatly appreciate it. KaFF Quote Link to comment Share on other sites More sharing options...
DBookatay Posted March 20, 2007 Share Posted March 20, 2007 You could do javascript... <script language="JavaScript"> function confirmLogout() { var agree=confirm("Are you sure you want to log out?"); if (agree) return true ; else return false ; } </script> then for a link <a href="logout.php" onClick="return confirmLogout()">logout</a> I just tried using this script on my site, exactly as it was written, and with both buttons "Cancel" and "Agree" I was still logged out... Quote Link to comment Share on other sites More sharing options...
jitesh Posted March 20, 2007 Share Posted March 20, 2007 <script language="JavaScript"> function confirmLogout() { if(!confirm("Are you sure you want to log out?")){ return false ; } </script> then for a link <a href="logout.php" onClick="return confirmLogout()">logout</a> 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.