• Hi, I’m working on a form page, and I would like to avoid that $_POST variables to be re-sent when I reload the page.
    Does anyone know how to achieve this function?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @antonop4u,

    You can look into using this javascript snippet:

    <script>
        if ( window.history.replaceState ) {
            window.history.replaceState( null, null, window.location.href );
        }
    </script>

    https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState

    But I would recommend that you redirect the user to a new page after you processed the $_Post values. That way the post values don’t get resend on refresh.

    Thread Starter antonop4u

    (@antonop4u)

    Thanks for your kind replay, I thought to the “new page redirecting” solution but I was hoping to be able to do it all on one page, of course, if it’s possible. I was going to set this as a fall back page to use in case that for some reason javascript does not work. In the end, probably I will split it into multiple pages if I can’t find a working solution. Thank you very much, Stephan I really appreciated the help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Form page $_POST deactivation on page reload’ is closed to new replies.