homepage Welcome to WebmasterWorld Guest from 54.167.138.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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

5+ Year Member



 
Msg#: 4305763 posted 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

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4305763 posted 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

5+ Year Member



 
Msg#: 4305763 posted 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

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4305763 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved