(php) how can I expire the previous page after any database transaction?

I am storing personal information in a PHP page. When the user clicks the submit button, it saves, but the user can return to the submit page via the browser's back button. Can I finish my previous page?

+2


a source to share


4 answers


You can use a token and set it in a hidden form, after submitting the form, you have to read the value of this hidden field and save in the session, and on the previous page, check that if a session is established, redirect the user to another location.



+1


a source


To prevent users from re-filling forms with the Back button or refreshing the page, you must follow the Submit Redirect design pattern .



+2


a source


You can use:

   session_destroy();

      

Or you can put this at the top of the page. When the user goes back, they will make a request for a new copy of the page:

<?php 
header("Cache-Control: no-cache, must-revalidate"); 
header("Expires: Sat, 07 June 1982 09:00:00 GMT"); // Past date 
?> 

      

0


a source


Just make the user stay on the same page throughout the entire process. So there is no page to go back at all.

They call it / Post / Redirect / Get . Very comfortably.

-1


a source







All Articles