Manat
10-06-2003, 03:17 PM
Hello all,
We will soon be having a banner on another site linking to ours.
I gave them an AFID=3243 query string.
I have a little counter that counts the number of users coming to our site with that affiliate ID.
Please critique my code and let me know if you would do anything differently.
Thanks.
<?php
$result = mysql_query ("SELECT * FROM counter");
//$rows = mysql_numrows($result);
for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
{}
$now = getdate();
$month = $now[mon];
$mday = $now[mday];
$year = $now[year];
$hours = $now[hours];
$min = $now[minutes];
$sec = $now[seconds];
$id = $count++;
$browser = "$HTTP_USER_AGENT";
$referer = "$HTTP_REFERER";
$time = "$year-$month-$mday $hours:$min:$sec";
for ($i=0; $i < strlen($id); $i++)
{
$sign = substr($id, $i, 1);
}
if ($referer != "$PHP_SELF")
{
if ($afid == 3243)
{
$counter = "INSERT INTO counter (ID, browser, referer, time, afid) VALUES ('$id','$browser','$referer','$time','$afid')";
$result = mysql_query($counter);
}
}
?>
I put the if referer not equal to self so that refreshes don't count as an extra visit.
Let me know if this a good solution to affiliate tracking/counting.
Thanks
MK
We will soon be having a banner on another site linking to ours.
I gave them an AFID=3243 query string.
I have a little counter that counts the number of users coming to our site with that affiliate ID.
Please critique my code and let me know if you would do anything differently.
Thanks.
<?php
$result = mysql_query ("SELECT * FROM counter");
//$rows = mysql_numrows($result);
for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
{}
$now = getdate();
$month = $now[mon];
$mday = $now[mday];
$year = $now[year];
$hours = $now[hours];
$min = $now[minutes];
$sec = $now[seconds];
$id = $count++;
$browser = "$HTTP_USER_AGENT";
$referer = "$HTTP_REFERER";
$time = "$year-$month-$mday $hours:$min:$sec";
for ($i=0; $i < strlen($id); $i++)
{
$sign = substr($id, $i, 1);
}
if ($referer != "$PHP_SELF")
{
if ($afid == 3243)
{
$counter = "INSERT INTO counter (ID, browser, referer, time, afid) VALUES ('$id','$browser','$referer','$time','$afid')";
$result = mysql_query($counter);
}
}
?>
I put the if referer not equal to self so that refreshes don't count as an extra visit.
Let me know if this a good solution to affiliate tracking/counting.
Thanks
MK