By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,446 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,446 IT Pros & Developers. It's quick & easy.

Submit vs. a fresh page load

P: n/a
I'm developing a page - mostly for the learning experience - that
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
submitted.

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
results shown.

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?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Martin <Martin <ma**********@comcast.net>> wrote:
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?

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
Jul 17 '05 #2

P: n/a
Martin wrote:
<cut>
Am I doing some wrong here or is that the way IE works?


I believe that IE even asks "Do you want to resent tehe information", or
something like that :-)
Basicly its up to the browser what to do because it can simply fetch the
page or resend your POST data.

gordan
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.