Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Submit vs. a fresh page load
September 21, 2004, 5:57 pm
rate this thread
includes a form with several text fields and a submit button. When
it's submitted, there is some server-side processing and the output is
displayed as part of the same page. (the form's action attribute is
set to: "<?php $PHP_SELF ?>").
One of the steps in the PHP script is to check for the existance of a
hidden element in the form so that I know whether the page is being
sent out as a result of a new request or from the form having been
This all works as expected. When the page is sent out as a result of
having been requested from its "home" page, the results are not shown;
when the submit button is clicked, the page is sent out with the
Finally my question: when viewing the page with the results shown, if
I press <F5> or click on "Refresh", it behaves as if I had clicked the
Submit button (that is, it shows the results). I would expect it to
return the page as if it was a new request (and NOT show the results).
Am I doing some wrong here or is that the way IE works?
Re: Submit vs. a fresh page load
It's not only how IE works, but how *ALL* browsers should work.
By clicking "Refresh", you want to reload the *current* page, which is the
result from sending the post data to the form. To do this, the IE (as every
other good browser) sends out exactly the same post data it sent for the
original request. Therefore you can't distinguish between a reloaded page
and a normal request with the same post data.
One possible solutions would be to save the data on the server, then
forwarding the user to another page, which displays the data.
Another solution would be putting an unique id into a hidden field and
saving it into a database and check whether the id is in the db, whenever
you recieve the form. If it is in the db, process the form data and remove
the id from the database, otherwise ignore the form data. (Don't forget the
error message so the user may obtain a "fresh" id.)
Simon Stienen <http://dangerouscat.net <http://slashlife.de
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle