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 Link to comment https://forums.phpfreaks.com/topic/43169-solved-logout-validation/ 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 } Link to comment https://forums.phpfreaks.com/topic/43169-solved-logout-validation/#findComment-209628 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> Link to comment https://forums.phpfreaks.com/topic/43169-solved-logout-validation/#findComment-209645 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 Link to comment https://forums.phpfreaks.com/topic/43169-solved-logout-validation/#findComment-210760 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... Link to comment https://forums.phpfreaks.com/topic/43169-solved-logout-validation/#findComment-210856 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> Link to comment https://forums.phpfreaks.com/topic/43169-solved-logout-validation/#findComment-211135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.