Does anyone know why a form would automatically resubmitted when the page is refreshed?
I an setting a javascript cookie to test whether or not to refresh the page - if it's 'YES' then do it etc... This is action on the body load event. The form submits through a hidden iFrame.
The trouble is, when this occurs the 'buy' button (submit) form on the page is resubmitted and thus returns to the page it's just returned from (the basket). This happens in FF but not in IE.
Any help appreciated.
A common approach to address this issue is to monkey with the POST recipient:
After the catching script has done all of the processing required by the POST, throw a Location:
header that redirects to the the currently requested URI. This has the affect of the browser recognizing the final destination as not having received a POST, and therefore refreshing won't resubmit the POST.
PHP Example
page.php
<?php
if (!empty($_POST)) {
// Do some stuff
header('Location: page.php');
// The second time around _POST won't have any data,
// so there's not worry of an infinite loop
exit;
}
?>
<h1>Hi, I will never try to resubmit POST data!</h1>
FireFox is designed to save your forms/inputs, which includes submit buttons.
This is really helpful when developing sites with forms so you don't have to keep filling them out, but it can get in the way sometimes, but it's a browser feature, not a code issue.
If you POSTed to get to the current page (instead of a post then a response.redirect to GET the current page), when you hit the browser's refresh button, it's going to re-POST. I'm not sure how that relates to your hidden Iframe issue, though. (It seems I'm duplicating what Shad just said, in essence).