homepage Welcome to WebmasterWorld Guest from 54.198.148.191
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How to avoid resending form data on page refresh
dbarasuk




msg:4305765
 7:31 am on Apr 29, 2011 (gmt 0)

Hi,
I realize that if i click on the refresh button of the browser after having submitted post data it is asking if i want to resend data again. Same if i click on the back button.

I am using the POST method
How can I avoid this?

Thank you in advance

 

eelixduppy




msg:4305916
 2:51 pm on Apr 29, 2011 (gmt 0)

You avoid this by having the form processing page (the "action" page) redirect to a display page once it is finished processing the submitted data. That way if the page is refreshed, it's the display page and not the processing page that gets refreshed. Unfortunately, if they hit back twice they will still get to submit the data again. This cannot be prevented, however, you can check server-side if they are submitting the same data a second time and prevent it.

Seb7




msg:4306115
 9:07 pm on Apr 29, 2011 (gmt 0)

could submit using ajax? or submit to a page that replies with a 204 status (doesnt change the page), or make the server side script detect duplicates.

g1smd




msg:4306170
 11:43 pm on Apr 29, 2011 (gmt 0)

Sometimes it is useful to be able to resubmit the form, especially when you have just been presented with a page containing an error message like: Network Timeout! The page you requested failed to return a response in a suitable time. or Transfer interrupted! The page you requested failed to respond.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved