开发者

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

开发者 https://www.devze.com 2022-12-30 22:59 出处:网络
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 p

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消