Home > Back-end >  Reload does not change POST state
Reload does not change POST state

Time:05-09

I have a problem where I want to reload the page on submit. I did this with the simple script function shown below. However, the echo'd "hello" does not disappear when I reload. Is there a reload function that changes the state of my submit post, and the "hello" is no longer appearing.

<!DOCTYPE html>
<html lang="en">
<body>
<form method="post">
    <button  type="submit" name="submit">Sign in</button>
</form>

<?php
if (isset($_POST['submit'])) {
    echo "hello";
    echo "<script>window.location.reload(true)<script>";
}

CodePudding user response:

If you want to redirect to a new page (or even the same page) but without POST values, then use

window.location.replace(url)

https://developer.mozilla.org/en-US/docs/Web/API/Location/replace

  • Related