tags:

views:

655

answers:

2

Does anyone know of a way to prevent the browser from asking the user to resend form information.

I know you can redirect the browser with:

<php
    header("location http://example.com");
?>

But this seems so inefficient and takes 2 request.

Hope you can help.

duplicate of: http://stackoverflow.com/questions/665399/how-do-i-stop-the-back-and-refresh-buttons-from-resubmitting-my-form

+5  A: 

Either redirect like your example, or use AJAX to submit the form in the first place. The browser has no way of requesting the same page without requesting the same page.

Not re-submitting the data would be the same as requesting a different page, so you're kinda stuck.

Ryan Graham
+4  A: 

As far as I know, there is nothing you can really do when it comes to that behavior in POST requests. The redirect, perhaps seemingly inefficient, is actually the best way to do it. You're telling the browser that you've done all the work necessary for the post request and now you're going to send it to a page that will never change, no matter how many times you call it, making it easily bookmarkable and reusable.

jsoverson