One possibility is to implement the post-redirect-get approach.
Simply put, a POST request will never be delivered to the browser. Instead, you perform all the necessary actions and store the necessary information in the session, and then you do the redirection with the code 303.
$page = 'show_result.php'; header('Location: '.$page, true, 303); exit;
By doing this, the browser will display the show_result.php page (GET request) instead of the page requested by POST. This is also a page added to the story, so updating and using the back button will never execute another POST request. As a good side effect, you get rid of browser warnings about sending data, usually the user cannot decide what to do, anyway.
I think the biggest problem with this approach is that you need a session to store error messages, which means you have to rely on cookies. If you do not redirect the error display, the browser will display a warning about data transfer.
source share