I'm a PHP Newbie: I want to check if the referer is from a certain domain
| From: | Joshua Prowse | Date: | Sun, 22 Jul 2001 19:42:00 +0000 |
| Subject: | I'm a PHP Newbie: I want to check if the referer is from a certain domain | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-8443@lists.php.net to get a copy of this message | ||
What I want to do: When a user views the page, I want to check whether
they're coming from another page on my site or whether this is the first
page that they're viewing. If it's the first page, then I want to echo some
code to the browser (it will read the cookie file for my site)
This is the code that I tried to use:
[code]
global $HTTP_REFERER;
$refp = parse_url($HTTP_REFERER);
$refr = $refp[host];
if ($refr != "rideau.prowsej.com")
{
echo "insert javascript here that the browser will execute";
}
[/code]
- My domain is rideau.prowsej.com
- The above code didn't seem to work.
It seemed that a lot of the time, the referer was null. Under what
conditions would the referer be null (where could I read about the
$HTTP_REFERER variable?)
Any help is much appreciated. Thanks.
- Joshua Prowse
Rideau High School Student