Well, what I actually had in mind was looking to see if the hostname was inside $_SERVER['HTTP_REFERER']:
$referer_bits = parse_url($_SERVER['HTTP_REFERER']);
if($referer_bits['host']=='www.mysite.com')
{// is there
}
if(substr($_SERVER['HTTP_REFERER'], 0, strlen("http://www.mysite.com/"))=="http://www.mysite.com/")
{// is there
}
if(strpos($_SERVER['HTTP_REFERER'],'www.mysite.com/'))
{ // is there
}
if(preg_match('#http://www.mysite.com/#', $_SERVER['HTTP_REFERER']))
{ // is there
}
If you want to change any of these to their opposite (so that the bit in {} is executed if the referring host was not www.mysite.com), then replace == with != or (if there is no == to replace), put a ! at the beginning of the test (so that where it says "if(" now, make it say "if(!".
I prefer one of the first two to either of the last two. The first two both have good points and bad points; the strpos() solution has a nasty kludge built into it that I'm not keen on; and I simply can't justify calling on the firepower inherent in preg_match() for such a straightforward task.