bpops Posted March 28, 2008 Share Posted March 28, 2008 I'm looking for a good / lite / easy to install Site tracking script using PHP/Mysql. Any recommendations? Link to comment https://forums.phpfreaks.com/topic/98384-recommend-a-php-site-tracking-script/ Share on other sites More sharing options...
helraizer Posted March 31, 2008 Share Posted March 31, 2008 It'd be very simple to write your own. Either flat file : php5 <?php $ip = $_SERVER['REMOTE_ADDR']; $filename = "hits.txt"; file_put_contents($filename, $ip, FILE_APPEND); $file = file("hits.txt"); $num = count($file); echo "This page has been viewed $num times"; ?> php4 $ip = $_SERVER['REMOTE_ADDR']; $filename = "hits.txt"; $fp = fopen($filename); fwrite($fp, $ip); fclose($fp); $file = file($filename); $num = count($file); echo "This page has been viewed $num times"; or with a database: assuming a table called hits with field IP(unique and primary key) $ip=$_SERVER['REMOTE_ADDR']; $sql = "REPLACE INTO `hits` (`IP`) VALUES ('$ip')"; $result = mysql_query($sql) or die("Error in sql: ".mysql_error()); $sql_a = "SELECT Count(ip) FROM `hits`"; $result_a = mysql_query($sql_a) or die("Error in sql_a: ".mysql_error()); $row = mysql_fetch_array($result_a); $num = $row['Count(ip)']; echo "this page has been viewed $num times"; Untested but should work. Only took maybe 3 minutes to write on the fly so just mess around with those. Unless you want an image based one.. Hope that helps Sam Link to comment https://forums.phpfreaks.com/topic/98384-recommend-a-php-site-tracking-script/#findComment-505833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.