Page 1 of 1

Login Previous Page

Posted: Tue Dec 22, 2009 4:50 pm
by jboku
Hey guys,

I have a script I've written and it's working except for 1 problem, if I try and use the $_SERVER['HTTP_REFERER']; to send it back to the previous page, it takes me to a blank page w/ nothing on it. If I set my variable to say, google.com it works fine.

Code: Select all

$ref=$_SERVER['HTTP_REFERER'];
header( 'Location:' .  $ref );
Basically I want the person who logs in to be sent back to the page they came from.

Any help would be greatly appreciated.

Thanks

Re: Login Previous Page

Posted: Wed Dec 23, 2009 2:11 am
by thefarhan
u should write direct path to that page like header(''location:login.php'');

Re: Login Previous Page

Posted: Wed Dec 23, 2009 12:51 pm
by AbraCadaver
And you can't always rely on HTTP_REFERE. You should set a session var on each page that holds the current page and then on your login page you can redirect back to that.

Re: Login Previous Page

Posted: Wed Dec 23, 2009 4:19 pm
by manohoo
I second AbraCadaver suggestion. If the page in question is bookmarked, and previous to that the user was in, let's say cnn.com... what would happen? An undesirable outcome!