There are Three methods of redirection is going to the previous page to simulate a back button click programmatically, here are some of the common way to go to the previous page using JavaScript's window object You can use any of the methods you want to use. Here Storing previous url in a session variable is bad, because the user might right click on multiple pages and then come back and save. But You can do better way using javascript.


window.history.back(); // Simulates a back button click
window.history.go(-1); // Simulates a back button click
window.history.back(-1); // Simulates a back button click

Just try this in Javascript:


$previous = "javascript:history.go(-1)";

Or you can try it in PHP:


if(isset($_SERVER['HTTP_REFERER'])) {
$previous = $_SERVER['HTTP_REFERER'];
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here

twenty − seven =