MrHus
MrHus

Reputation: 33378

Prevent browser from re-sending form information

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: How do I stop the Back and Refresh buttons from resubmitting my form?

Upvotes: 0

Views: 2143

Answers (2)

jsoverson
jsoverson

Reputation: 1717

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.

Upvotes: 5

Ryann Graham
Ryann Graham

Reputation: 8229

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.

Upvotes: 5

Related Questions