yakabod Posted September 15, 2008 Share Posted September 15, 2008 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! Link to comment https://forums.phpfreaks.com/topic/124256-recommendation-on-php-unique-visit-counter-script/ Share on other sites More sharing options...
DarkWater Posted September 15, 2008 Share Posted September 15, 2008 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. Link to comment https://forums.phpfreaks.com/topic/124256-recommendation-on-php-unique-visit-counter-script/#findComment-641640 Share on other sites More sharing options...
yakabod Posted September 15, 2008 Author Share Posted September 15, 2008 Well, Do you know a script that can do that and be visible in my sites footer? Link to comment https://forums.phpfreaks.com/topic/124256-recommendation-on-php-unique-visit-counter-script/#findComment-641661 Share on other sites More sharing options...
M.O.S. Studios Posted September 15, 2008 Share Posted September 15, 2008 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 Link to comment https://forums.phpfreaks.com/topic/124256-recommendation-on-php-unique-visit-counter-script/#findComment-641685 Share on other sites More sharing options...
DarkWater Posted September 15, 2008 Share Posted September 15, 2008 M.O.S, you can solve problem #3 by changing your session.save_path in php.ini to .yourdomain.com (notice the . in front). Link to comment https://forums.phpfreaks.com/topic/124256-recommendation-on-php-unique-visit-counter-script/#findComment-641835 Share on other sites More sharing options...
M.O.S. Studios Posted September 15, 2008 Share Posted September 15, 2008 oh yeah, this is for the footer if($newvalue) {echo $newvalue;} else {echo $_SESSION['countmain']="1";} just place that into the footer. you can use tables to jazz it up a bit Link to comment https://forums.phpfreaks.com/topic/124256-recommendation-on-php-unique-visit-counter-script/#findComment-642106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.