How to Delete $_POST Variable On Page Refreshing with PHP

The $_POST variable stores all the information that is sent to a PHP page via the POST method. This can include text input, files uploaded, and data from form fields. If you want to delete this information when the page refreshes, you can use the PHP unset() function.

The $_POST variable keeps all the data that is sent to a PHP page via the POST method, even if the page is reloaded. This can include text input, files uploaded, and data from form fields. If you want to delete this information when the page refreshes, you need to implement a workaround.

When you make an online request, the data in your POST headers is sent again no matter what you do. The most simple solution would be to redirect users back instead of sending them new information each time they refresh their browser window or tab.

//redirect user to any page
header('Location: https://example.com/form-handling/');
header('Location: ' . $_SERVER['HTTP_REFERER']);
header("Location: ".$_SERVER['REQUEST_URI']);

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close