If you wish to know what page was the previous page the visitor visited prior to this page you can use:
1 2 |
$testurl=$_POST['urlbefore']; if (!is_null($testurl)) {$urlbefore=$_POST['urlbefore'];} else {$urlbefore= $_SERVER['HTTP_REFERER'];} |
I’m using this in forms and I simply add the value of “$urlbefore” to a hidden field.
The code above also makes sure that submitting the form does not change the url since it is reassigned to its previous value, if exists.