Use IP addresses to count the number of visitors! Take the day as the limit!
Source: Internet
Author: User
& Lt ;? & Nbsp; require ('Common. inc '); & nbsp; & #36; ip & #36; REMOTE_ADDR; & nbsp; & #36; currentgetdate (time ()); & nbsp; & #36; day & #36; current [mday]; & nbsp; 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 number". $ num;
Echo "visitor ";
$ Query1 = "insert into count values ('$ IP', $ day, $ num )";
MySQL (best combination with PHP) _ db_query ('football', $ query1, $ link );
}
Else
{
Echo "you are the number". $ 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 ","");
?>
Library:
Football
Table:
Count
Field: ip-> char (20)
Day-> int (2)
Num-> int (8)
This program can be used as a multi-user stenographer with slight modifications, and cannot be falsified!
For personal use only!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service