Home >Backend Development >PHP Tutorial >Use IP addresses to count the number of visitors! The limit is heaven! _PHP Tutorial

Use IP addresses to count the number of visitors! The limit is heaven! _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:31:331146browse

require ('common.inc');
$ip=$REMOTE_ADDR;
$current=getdate(time());
$day=$current["mday"] ;
$query="select * from count";
$result=MySQL(The best combination with PHP)_db_query('football',$query,$link);
while($row=MySQL(The best combination with PHP)_fetch_row($result))
{
$num=$row[2];
if ( strcmp($ip,$row[0])==0 && $day==$row[1])
{
$i=1;
}
}
if ( $i<>1)
{
++$num;
echo "You are the" .$num;
echo "Visitor";
$query1="insert into count values ​​('$ip',$day,$num)";
MySQL(The best combination with PHP)_db_query('football',$query1,$link);

else 

echo "You are the" .$num; 
echo "Visitor"; 

?> 

common. inc:
$arr_request=array();
if (count($HTTP_GET_VARS))
{
while (list($key,$value)=each($ HTTP_GET_VARS))
{
$arr_request[strtolower($key)]=$value;
}
}
if (count($HTTP_POST_VARS))
{
WHILE (list($key,$value)=each($HTTP_POST_VARS))
{
$arr_request[strtolower($key)]=$value;
}
}
$link= MySQL(The best combination with PHP)_connect("localhost","root","");
?>

The library is:
football
Table:
count
Field: ip->char(20)
day->int(2)
num->int(8)
This program is slightly modified It can be modified to become a multi-user counter, and it cannot be faked!
For personal use only!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509062.htmlTechArticle? require ('common.inc'); ip=REMOTE_ADDR; current=getdate(time()); day =current["mday"]; query="select * from count"; result=MySQL (the best combination with PHP) _db_query('foot...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn