sepoto Posted August 3, 2011 Share Posted August 3, 2011 Is there a way to tap into the refresh event with PHP? Ideally I want to handle only the refresh event if certain conditions are met such as the user refreshed by use of the browser refresh button or context menu... I've never seen code for this so it is all new to me. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2011 Share Posted August 3, 2011 PHP doesn't handle browser events, Javascript does. There's not a refresh event, but there are load and unload events. Link to comment Share on other sites More sharing options...
jeffman Posted August 3, 2011 Share Posted August 3, 2011 @sepotoFor a situation like this, it might be better if you described your problem. Guessing at a solution and asking questions only about that will delay your progress if you have made a poor guess.In another thread, someone suggested that you are trying to keep the same POST request from doing something on your server more than once. I don't know if that's correct. If it is, please say so. A variety of solutions to that problem are well-known. Link to comment Share on other sites More sharing options...
sepoto Posted August 3, 2011 Author Share Posted August 3, 2011 I'm trying to explain the best I can. I have a form and some code to check if the method is POST. If the method is POST some mapping code is echoed below the form. When I hit refresh in my browser it just resubmits the same information from the form so I still see my mapping code being echoed. When I refresh I want the mapping code to not execute in other words the method for the form should be GET on reload so that no mapping code is being echoed. Can this be done? I tried using header(); as in a previous post but that did not really seem like my solution. Link to comment Share on other sites More sharing options...
jeffman Posted August 3, 2011 Share Posted August 3, 2011 Refresh will reload the document the same way it was requested. You can't really change that. I guess the point of sending a location header was to force the browser to load a new version of the document with a GET request. Did that not work?Have you tried setting a session variable? Execute the code if the variable is not set, don't execute it if is. Set the variable the first time the code executes. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.