Web Hosting Talk







View Full Version : Referer Script Help


WreckRman2
09-03-2001, 03:39 AM
I added the following to my pages to help track referers from my site. Does anyone know how I can make it only insert those coming from outside my own domain?

$referer = "$HTTP_REFERER";
$stats = "$REMOTE_ADDR - $HTTP_USER_AGENT";

$sql = "INSERT INTO referer (id, referer, stats) VALUES ('null', '$referer', '$stats')";
$result = mysql_query($sql);



Examples:

Want to keep because lists search engine keywords and such...

http://www.google.com/search?q=123+gift+shopping&btnG=Google+Search

64.193.141.201 - Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)


Don't really need because it is only page browsing from within the site...

http://www.123giftshopping.com/view.php?page=recommend&productid=24

64.193.141.201 - Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)

-----------------------------------

Maybe something like:

if ($HTTP_REFERER=="http://www.123giftshopping.com") {
do nothing;
} else {
do insert;
}

iplexx
09-03-2001, 07:28 AM
Following code should do it (written out of my mind, untested)


if (strpos($HTTP_REFERER,$SERVER_NAME)>0)
{ echo "local referer"; } else
{ echo "external referer"; }