Hi:
How do i get the last page visited? for example a back button that returns to whatever page it came from.
in a script i have:
header("Location: index.php");
but i want it to direct back to the previous page not a predefined one.
Thanks.
Getting last page visited
Moderator: General Moderators
$_SERVER['REFERER']
But you can't rely on it for anything serious, because it can be easily circumverted. After all, it depends on the browser to tell the server where it came from. If the browser can do that, so can you.
But you can't rely on it for anything serious, because it can be easily circumverted. After all, it depends on the browser to tell the server where it came from. If the browser can do that, so can you.
Yep, you have to tell the browser what to do with the referring URL. If ya don't, it won't know!Sid3335 wrote: header($_SERVER['HTTP_REFERER']);
but it wasn't working, so i tried:
header("Location:".$_SERVER['HTTP_REFERER']);
Remember, you can do lots of things with header() other than redirecting, lots more. Even more than that. Yea, that's better.