Page 1 of 1
checking if a "refresh" was done!
Posted: Mon Jun 06, 2005 7:43 am
by pelegk2
how can i check if the user pressed "F5" (refresh?)
beacuse for example if he has filled out data in a table and after i hhave aupdated he presses F5 the update will be done again!
how can i find thatout and even prevent it?
thnaks i nadvance
peleg
Posted: Mon Jun 06, 2005 7:45 am
by malcolmboston
it can be stopped using javascript (the F5 press) however, there is no real sure-fire way of stopping it, theres too many ways a user could refresk, press return on address bar, press refresh icon, press f5 etc etc
well
Posted: Mon Jun 06, 2005 7:52 am
by pelegk2
press return on address bar is not the same as press refresh icon, press f5 beacuse the first one is calling the page withought sending a form variables
where as for refresh icong/f5 it is!
Posted: Mon Jun 06, 2005 8:01 am
by malcolmboston
if you press return on the address bar on a page that processes $_POST information, then it resends in the $_POST variables
at least it has for as long as ive been using browsers (a long time)
it may not technically be a refresh, but you are getting back exactly the same information on exactly the same page, so i would call it a refresh
Posted: Mon Jun 06, 2005 8:11 am
by JayBird
malcolmboston wrote:if you press return on the address bar on a page that processes $_POST information, then it resends in the $_POST variables
at least it has for as long as ive been using browsers (a long time)
not since i have been using browsers it doesn't
Hit refresh or F5 and it does, but not return in the address bar
Posted: Mon Jun 06, 2005 8:15 am
by malcolmboston
lol, my bad, i was thinking $_GET even though i clearly stated $_POST

Posted: Mon Jun 06, 2005 8:18 am
by malcolmboston
could the problem not be solved by...
Code: Select all
// at end of page
if (isset($_POST))
{
unset($_POST);
}
then when it was refreshed, the post data would not be available?
Posted: Mon Jun 06, 2005 8:50 am
by CoderGoblin
My normal method of preventing update is
Code: Select all
if ($_REQUESTї'var']) {
//Perform Update
header("e;Location: url"e;);
exit;
}
Where url is the page again with any $_GET variables required to show the correct information.
No matter how the page is refreshed the update is not done again.