dbgohan Posted August 25, 2007 Share Posted August 25, 2007 Hello, I was wondering if there is a way to disable or detect when a user presses the browser back button in PHP. What I want to do is that when a back button is pressed, the page reloads. Please let me know if there is a way to do this. If any of you use modernbill, it has that feature. Thanks Link to comment https://forums.phpfreaks.com/topic/66690-detectingdisabling-back-button-using-php-reload-page-when-back-button-pressed/ Share on other sites More sharing options...
php_tom Posted August 25, 2007 Share Posted August 25, 2007 Actually I could see that being REALLY annoying, depending on what exactly you're doing... But maybe you can use JavaScript's onUnload event? E.g.: <BODY onUnload="window.location.href=thisPage.html;"> Hope that helps... Link to comment https://forums.phpfreaks.com/topic/66690-detectingdisabling-back-button-using-php-reload-page-when-back-button-pressed/#findComment-334112 Share on other sites More sharing options...
dbgohan Posted August 25, 2007 Author Share Posted August 25, 2007 Actually I could see that being REALLY annoying, depending on what exactly you're doing... But maybe you can use JavaScript's onUnload event? E.g.: <BODY onUnload="window.location.href=thisPage.html;"> Hope that helps... What I am trying to do is this. For example if a client wants to update his/her info, they modify the info in the form and press the update button, the script then updates their info in the database and notifies the user. Now lets say they press the back button to go back to the modify page, what I want to do now is rather than display the information in the form that was there before (chaching) I want the script to retrieve the real data from the database and display it in the form. I Hope that is clear. Thanks Link to comment https://forums.phpfreaks.com/topic/66690-detectingdisabling-back-button-using-php-reload-page-when-back-button-pressed/#findComment-334121 Share on other sites More sharing options...
php_tom Posted August 25, 2007 Share Posted August 25, 2007 I think I see what you mean. Here's what I found on http://us3.php.net/header: PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with: <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> If you put something like that at the top of the page you don't want to be cached (before you begin output), maybe that will do the trick. Link to comment https://forums.phpfreaks.com/topic/66690-detectingdisabling-back-button-using-php-reload-page-when-back-button-pressed/#findComment-334129 Share on other sites More sharing options...
dbgohan Posted August 25, 2007 Author Share Posted August 25, 2007 That does not seem to work. When I press the back button, it gives me the page expired error. Error: --------------- Webpage has expired Most likely cause: The local copy of this webpage is out of date, and the website requires that you download it again. What you can try: Click on the Refresh button on the toolbar to reload the page. After refreshing, you might need to navigate to the specific webpage again, or re-enter information. More information If you continue to have this problem, try the following: In Internet Explorer, click Tools, click Internet Options, and then click the Advanced tab. Scroll down and uncheck the "Do not save encrypted pages to disk" option in the Security settings. Link to comment https://forums.phpfreaks.com/topic/66690-detectingdisabling-back-button-using-php-reload-page-when-back-button-pressed/#findComment-334154 Share on other sites More sharing options...
dbgohan Posted August 27, 2007 Author Share Posted August 27, 2007 any help guys? Link to comment https://forums.phpfreaks.com/topic/66690-detectingdisabling-back-button-using-php-reload-page-when-back-button-pressed/#findComment-335020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.