rsammy Posted May 14, 2007 Share Posted May 14, 2007 is there a way to disable the Back button on the browser? i would like to prevent users from using it to go to the previous page! Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/ Share on other sites More sharing options...
Dragen Posted May 14, 2007 Share Posted May 14, 2007 I don't think so. Your best bet is opening the page in a window (using javascript) with the toolbars etc removed. Or if you can somehow remove the users history, but I'm not sure if you can do that and many people would not be happy if you did anyway. Someone please correct me if I'm wrong.. If you're not wanting people to go back to a certain page from a certain page I'm sure you can have an if statement checking what page you were sent to the page from. If it's one you don't want it to be accessed from, then it sends an error message. Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-252946 Share on other sites More sharing options...
lewis987 Posted May 14, 2007 Share Posted May 14, 2007 just force the previous page to "expire" thats the only way from stopping people from viewing what was sent, but some browsers (like opera) keep everything in cache, so really, there is no way of stopping people from going to the previous page Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-252978 Share on other sites More sharing options...
Dragen Posted May 14, 2007 Share Posted May 14, 2007 just out of curiosity.. why would you want to stop the user being able to go back? Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-253080 Share on other sites More sharing options...
rsammy Posted May 14, 2007 Author Share Posted May 14, 2007 just force the previous page to "expire" thats the only way from stopping people from viewing what was sent, but some browsers (like opera) keep everything in cache, so really, there is no way of stopping people from going to the previous page how do i do this? Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-253126 Share on other sites More sharing options...
rsammy Posted May 14, 2007 Author Share Posted May 14, 2007 just out of curiosity.. why would you want to stop the user being able to go back? ok. i have to implement the logout stuff. when logout is clicked on screen, i send it to logout.php where i am doing this... <?PHP //require_once ("phpInclude/config.php"); require_once ("../config.php"); header("Expires: Mon, 26 Jul 2001 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>INSTICOMM</title> <link rel='stylesheet' type='text/css' href='css/styleSheet.css'> <Script language=javascript> </Script> </head> <BODY onload="window.scroll(0,yoffset)"> <table width="900" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="4" bgcolor="#FFFFFF"> <div align="left"><font color="#FFFFFF"></font></div> <div align="right"><font color="#FFFFFF"><img src="images/title_barom.jpg" width="900" height="69"></font></div></td> </tr> <tr> <td align="left" valign="top" width="300"> <table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top"> <SCRIPT language="JavaScript"> tree.loadState() tree.display() </SCRIPT> </td> </tr> </table> <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">***********************<br> XYZ Software<br> Version <? print("$version"); ?><br> *********************** <? if ($demo_disclaimer_option =='ON') { print("<br>"); print("<b>$demo_disclaimer1</b>"); print("<br>"); print("$demo_disclaimer2"); } ?> </p> <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><? print("<b>$copyright1</b>"); ?></p> </td> <td colspan="3" align="left" valign="top"> <br> <br> <table width="450" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#006699"> For security reasons, please close your browser immediately. </table> </body> </html> still, when Back button is clicked on browser, it goes back. Its another thing that it wont let be do anything when I click some link or button on the previous page(after clicking Back button). It will take me to the login screen. but, still, as long as i keep clicking back button, it takes me through all thepages showing all of the info on screen!! is there a way to block that? thanx Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-253129 Share on other sites More sharing options...
Dragen Posted May 14, 2007 Share Posted May 14, 2007 yeah. set up a function which checks if you're logged in or not. I'm not sure how you've set up your log-in system, but on mine I've got a global variable called $logged_in which will either be true or false. If true, then you are logged in. If false then you are not. I have a function like this: function isLogin(){ global $logged_in; if(!$logged_in){ header("location:/index.php"); exit; } } which I run at the top of every page I want only viewable to logged in users. If the user isn't logged in it sends them to my index.php file. Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-253133 Share on other sites More sharing options...
rsammy Posted May 15, 2007 Author Share Posted May 15, 2007 thanx. lemme try that Quote Link to comment https://forums.phpfreaks.com/topic/51364-back-button-on-browser/#findComment-253872 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.