Please anyone can help me to create a code that count all the Unique IP visitor for a site?
Ip counter
Collapse
X
-
Sql
PHP Code:CREATE TABLE `user_ips` (
`id` int(100) NOT NULL auto_increment,
`ip` varchar(30) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `ip` (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
PHP Code:$ipcount = mysql_fetch_array(mysql_query("SELECT id FROM user_ips WHERE ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."'"));
if($ipcount[0]<1){
mysql_query("INSERT INTO user_ips SET ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."'");
}
$ipcount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM user_ips"));
print $ipcount[0].' Unique Visitors';
Comment
Comment