Thursday, January 31, 2019

php - Read session when click back button instead of $_POST value

I have 3 page, and pass value using $_POST method. The reason not using $_GET method is I don't want user go to the url and change the value and able to pass value. From the beginning for t2 and t3 page:




  1. t2 and t3 will check if(isset($_POST)) then save to the session.

  2. When t3.php user click on back button, t3 not passing $_POST data and read session




It is able to work when passing data from t1 to t2 and t2 to t3, but when click on back button from t3 to t2, the browser show "Confirm Form Resubmission". How can I make the page read the session data instead of the $_POST value when user hit the back button?



t1.php






value1:

value2:








t2.php




session_start();

if(isset($_POST)){
unset($_SESSION['t2']);
$_SESSION['t2']=$_POST;
}else if(isset($_SESSION['t2'])){

}else{
header("Location: http://localhost/my_project/t1.php");
}


?>



value1!
value2 .


value1:

value2:









t3.php




session_start();

if(isset($_POST)){
unset($_SESSION['t3']);
$_SESSION['t3']=$_POST;
}else if(isset($_SESSION['t3'])){

}else{
header("Location: http://localhost/my_project/t1.php");

}

?>



value1!
value2 .




No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...