I am saving personal information in PHP page.when user clic开发者_如何转开发k submit it saves but user can go back in submit information page through browser back button.Hoe can I expire my previous page??
To prevent users from resubmitting forms by using the back button, or refreshing the page, you need to follow a design pattern called Post Redirect Get.
You can use a token and set in a hidden filed, once form is submitted, you should read the value of that hidden field and store in a session and on previous page make a check that if session is set, redirect user elsewhere.
You could use:
session_destroy();
Or you could put this at the top of the page. When user hits back it 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
?>
Just make user stay on the same page through the whole process. So, no page to get back at all.
They call it /Post/Redirect/Get pattern. Very handy.
精彩评论