Page 1 of 1

knowing from what page I came from

Posted: Tue Jan 11, 2005 7:33 am
by jasongr
Hello people

I have 3 pages in the application
both page A.html and page B.html have a link to page C.php
When I get to page C.php I need to know from what page I came from.

I know that I can pass it as a parameter in the URL, but I was wondering if there is a more basic construct in PHP that will allow me to know this without having to perform an explicit action

regards

Posted: Tue Jan 11, 2005 8:00 am
by protokol
You could check the value of $_SERVER['HTTP_REFERER']. However, it isn't guaranteed to always be set.

Posted: Tue Jan 11, 2005 8:21 am
by jasongr
thanks, I will check it out
If it won't work, I will have to take care of it explicitly when I construct the URL to C.php

Posted: Tue Jan 11, 2005 1:03 pm
by rehfeld
jasongr wrote:thanks, I will check it out
If it won't work, I will have to take care of it explicitly when I construct the URL to C.php

you may want do that anyway.

the referer header is optional, meaning browsers do not need to send it. many dont.