Hello, I’m new to this site and PHP; so hi to everyone.
I have a little problem with $HTTP_RERERER function. I want to track hits in from partner sites using HTTP_REFERER. After spending hours on the script and Google, I have got it to work on the most part. Now what happens is, if someone re-loads the page. It keeps on increasing the hits in from referring partner. I want it to count only the first hit. Here is the code:
<?php
$ref = $_SERVER[‘HTTP_REFERER’];
if(empty($ref)) {
$site = ‘none’;
}
else
{
$site = $_SERVER[‘HTTP_REFERER’];
}
$site = str_replace(“http://”,””, $site);
$site = explode(“/”, $site);
$theSite = $site[0];
$Referers = mysql_query(“SELECT * FROM Links”) or die(mysql_error());
while ($Referer = mysql_fetch_array($Referers)){
$HitCount = $Referer[‘HitsIn’];
$UpdatedHits = $HitCount +1;
if ($Referer[‘lDomain’] == $theSite){
$RefUpdate = “UPDATE Links SET HitsIn=$UpdatedHits WHERE lDomain=’$theSite'”;
mysql_query($RefUpdate);
}
}
?>
I don not want to use another file to redirect E.g. (Hitin.php?ID=10) because this will not increase my Google PR.
Thank you very much for your help.