Post/Redirect/Get on same page with firefox [close

2019-09-09 02:30发布

My workaround getting the "Resubmit post data" dialog when users refresh, and respectively sending stuff twice, was to force a refresh on the page via javascript when content is posted. Which seemed to work in webkit browsers and IE but unfortunately firefox doesn't work that way.

The problem is that after the post I need the user to be returned to the same page which kinda confused me on using the post/redirect/get method since it is described there that another page needs to be supplied. Even if I send a redirect header from php itself firefox still asks about resubmitting. Can anyone suggest how I can solve this problem? Thank you in advance!

EDIT: Here's some code

if($_SERVER['REQUEST_METHOD']=="POST"){
    $user->validateSettingsData($_POST, TRUE);
    echo "<div class='win box10'>Changes saved, please wait..</div>";

    header("Refresh: 2; url=");
    exit();
}

标签: php http post
1条回答
The star\"
2楼-- · 2019-09-09 02:56

You can use PHP to redirect. For example:

if (isset($_POST)) {
    // processing the data
    // ....

    header('LOCATION: ' . $_SERVER['REQUEST_URI']); // <-- for dynamic URL
    exit();
}
查看更多
登录 后发表回答