Can you resubmit automatically without need for refresh?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Can you resubmit automatically without need for refresh?

Post by mjseaden »

Dear All

Commonly when I am POST-ing information from one page to another, when I press back I (seemingly randomly) get the typical 'Web Page Has Expired' message, and the request to refresh.

Is there any way I can get it to refresh automatically (on all platforms) without the need to hit the refresh button, and therefore get rid of these unprofessional-looking messages?

Many thanks

Mark
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

No there isn't. This is built into the browser. The reason it says the page has expired is of course because the POST variables are part of the page, and after the form has been submitted, the page no longer exists (kind of). The only pseuod-way to get around this is to put a "back" link in your page somewhere.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Yea, thats what I do, only get the post variables for the form when leaving the page, not when entering the next page. Some people still insist on that back button, though! How does this site do it?
aleigh
Forum Commoner
Posts: 26
Joined: Thu Mar 25, 2004 11:06 am
Location: Midwestern United States
Contact:

Re: Can you resubmit automatically without need for refresh?

Post by aleigh »

mjseaden wrote:Dear All

Commonly when I am POST-ing information from one page to another, when I press back I (seemingly randomly) get the typical 'Web Page Has Expired' message, and the request to refresh.

Is there any way I can get it to refresh automatically (on all platforms) without the need to hit the refresh button, and therefore get rid of these unprofessional-looking messages?

Many thanks

Mark
The problem that you are describing is that the browser has returned to an URL that required POST data. Browsers handle this differently but basically the browser is giving you the dialog because it is concerned that by re-posting the form variables it will cause a side-effect operation like buying you an extra digital camera on amazon.

I have not found any really swell answers to this problem, but I will share one idea; when you 302 the incident page that generated the 302 is stripped from the browsers page. For example

A -> B(302) -> C

When you hit back on C you will go to A, not B. Therefore if you store the result data in the session and 302 them once you receive the post data they will arrive at a page that they will GET rather than POST therefore avoiding the error should they hit back.

I almost feel embarassed suggesting this, so take that for whatever it might be worth.

I generally just live with the problem and try to provide them sufficient in-page navigation that they do not use the back button, but it's a hard habit to break for sure.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

I have completely gotten rid of that message. After my script processes the post request I do a location header at the bottom (usually back to the same page)... this breaks the request/response cycle.
Post Reply