set a hidden form element to be the referring page url, then use that to
redirect the user
eg: <input type="hidden" name="myReferer" value="<?=
then use: header("location: $myReferer");

remember, also, that $_SERVER['HTTP_REFERER'] is not always set, so you'll
need to cater for that


-----Original Message-----
From: Jiaqing Wang [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 5:42 PM
Subject: [PHP] Using HTTP Referer 

Hello, All,
I'm currently working on a problem which is in need of HTTP referer or the
similar technique, but I couldn't seem to find any article or links which
illustrate the idea, I tried $_SERVER['HTTP_REFERER'] but somehow it didn't
work for me. Let me breifly explain what I did here:

I have login page called login.php, in this page I do

1. verify user the username and password against my backend database.
2. once passwd is verified, opens up a session with this login session.
3. header("Location: ${_SERVER['HTTP_REFERER']}") this will send user who
just logged in back to the whichever page they came from.

I also have a bunch of service scripts providing the content of my site like
mysite.php which invokes the login.php page if it determines that the user
is not logged in, after user goes through the logging in process, the
login.php will re-direct it back to this particular page, of course the
location of the page is dynamicly determined by HTTP_REFERER.

The problem I'm having right now is that after the user is logged in, the
login.php can never send it back to the page the user came from, it will
just redraw the login.php page. Obviously, $_SERVER['HTTP_REFERER'] contains
the location of itself instead of the location of the page sent the user

I hope this is clear to you, if any of you out here knew a clue please help
me out. Any comment is greatly appreciated.


PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to