Page 1 of 1
Redirecting a user back to where they came from
Posted: Tue Dec 02, 2003 5:19 am
by hibbeac1
Hi,
I was wandering how to redirect users back to where they came from if they go to a page that they do not have access to. They won't always come from the same page of course.
Thanks again
Posted: Tue Dec 02, 2003 5:23 am
by markbeadle
Use global value $HTTP_REFERER
Posted: Tue Dec 02, 2003 5:25 am
by Weirdan
$HTTP_REFERER is deprecated, use $_SERVER["HTTP_REFERER"] instead.
Or use js: history.go(-1)
Posted: Fri Dec 05, 2003 8:22 am
by hibbeac1
I've tried doing this but it didn't work. It came up with the can't find page error. This is how i tried to do it.
header ("Location: http:// . $_SERVER['HTTP_REFERRER']");
Posted: Fri Dec 05, 2003 10:03 am
by Weirdan
hibbeac1 wrote:I've tried doing this but it didn't work. It came up with the can't find page error. This is how i tried to do it.
header ("Location: http:// . $_SERVER['HTTP_REFERER']");
Code: Select all
header("Location: ".$_SERVER['HTTP_REFERER']);
//or
header("Location: {$_SERVER['HTTP_REFERER']}");
[Changed REFERRER -typo to REFERER --JAM]
Thanks, Jam, I missed the double R
Posted: Fri Dec 05, 2003 12:07 pm
by Chambrln
If you are using Dreamweaver MX (not MX 2004) to code and you use the auto complete function for HTTP_REFERER it has a typo and puts in an extra R giving you HTTP_REFERRER