divadiva Posted September 5, 2008 Share Posted September 5, 2008 I have a webpage and I want to know how many different people are visiting my webpage.Is there a way to do that. I have use hit counter.It tells me the total number of hits.I want to track different IP addresses/people.Is there a way to do it. Thankyou in advance. Best Regards Gagan Link to comment https://forums.phpfreaks.com/topic/122879-solved-hit-counter/ Share on other sites More sharing options...
Jabop Posted September 5, 2008 Share Posted September 5, 2008 http://www.google.com/analytics/ Link to comment https://forums.phpfreaks.com/topic/122879-solved-hit-counter/#findComment-634623 Share on other sites More sharing options...
discomatt Posted September 5, 2008 Share Posted September 5, 2008 Very easy with a database. ON every page, execute a query like this INSERT INTO `counter` (`ip`) VALUES ( '{$_SERVER['REMOTE_ADDR']}') Then to view hits, simply use SELECT COUNT(*) as `total`, COUNT(DISTINCT `ip`) as `unique` FROM `counter` Link to comment https://forums.phpfreaks.com/topic/122879-solved-hit-counter/#findComment-634628 Share on other sites More sharing options...
divadiva Posted September 5, 2008 Author Share Posted September 5, 2008 Thanks for replying!! I am trying this codewhich I have taken from web <? $db = mysql_connect("172.16.24.3", "gvirk", "G@g@n1"); mysql_select_db("test",$db); mysql_query("UPDATE user_hits SET counter=counter+1 WHERE page = '$PHP_SELF' AND ip='$ip' AND ref='$HTTP_REFERER' ",$db); if (mysql_affected_rows($db) < 1) { $result = mysql_query("INSERT INTO user_hits VALUES ('$PHP_SELF', '$ip', '$HTTP_REFERER', 1)", $db); } mysql_close($db); ?> But I get an error that httpreferer,phpself is not defined.Can anyone guide me through this? Thankyou in advance Best Regards Divya Link to comment https://forums.phpfreaks.com/topic/122879-solved-hit-counter/#findComment-634643 Share on other sites More sharing options...
discomatt Posted September 5, 2008 Share Posted September 5, 2008 Those use old variables. Also you may want to edit out your DB password next time Change $PHP_SELF to $_SERVER['PHP_SELF'] and $HTTP_REFERER to $_SERVER['HTTP_REFERER'] Link to comment https://forums.phpfreaks.com/topic/122879-solved-hit-counter/#findComment-634659 Share on other sites More sharing options...
divadiva Posted September 8, 2008 Author Share Posted September 8, 2008 I tried Google Analytic and it is a good tool. Thanks experts for helping!! Link to comment https://forums.phpfreaks.com/topic/122879-solved-hit-counter/#findComment-636684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.