Say I'm on /page_1.php. I run the following code under a certain condition:
global $URL_BEFORE_PAGE2;
$URL_BEFORE_PAGE2 = $_SERVER['REQUEST_URI'];
header('location: /page_2.php');
I am now on /page_2.php. This page contains the following link:
<a href="<?=$URL_BEFORE_PAGE2?>">Return to Previous Page</a>
PROBLEM: The link using $URL_BEFORE_PAGE2 points to /page_2.php instead of the expected /page_1.php.
I assume the problem is that $URL_BEFORE_PAGE2 is storing a reference to $_SERVER['REQUEST_URI'] instead of just storing the value. How can I keep the original value of $URL_BEFORE_PAGE2 without it updating every time $_SERVER['REQUEST_URI'] changes?