Jump to content

Recommendation on PHP Unique Visit Counter Script?


yakabod

Recommended Posts

Was searching around Google and didn't find a script that was easy to install and that works well.  Do you guys know a PHP script that you guys recommend that will actually count the actual UNIQUE VISITS?  I want to be able to know the number that actually checks out my site.  I don't want to see a high number because one person chose to keep refreshing my homepage just so the number is high. lol.

 

 

Thanks!

Just store every IP in the database and update a count column if the IP is already in the db, otherwise insert a new row.  I mean, that's just if you want unique visitors.  I like to track browsers and IPs and pages accessed usually.  Therefore, I just insert a new row every time and do some queries to get the info I want.

this is one i wrote, i took it directly from my site.

 

session_start();

include("common/link.php");

$counter=mysql_query("SELECT * FROM hits WHERE `index` = 1");

$counter_input = mysql_fetch_array($counter);

if($_SESSION['countmain']!="1")

{

$_SESSION['countmain']="1";

$newvalue = $counter_input['main']+1;

$query="UPDATE hits SET main = ".$newvalue." where `index` = 1";

mysql_query($query);

}

mysql_close($link);

 

bassicly it will give you +1 for every unique visit.

 

notable exceptions:

1. if the user closed the browser then loggs back on it will count as two hits,

2. if the user loggs on with another web browser it will count as two hits

3. if the user takes out the www from the url iut will count as two hits

 

 

how ever if they log on then goto another website then go back with out closing the browser it wont count as two hits

 

you also have to make a table called hits with one col named index (that has a value of 1) and another called main

 

and last but not least you will have to replace the include("link.php"); with your db info

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.