Use the IP address to count the number of visitors! The sky is the limit!

Source: Internet
Author: User
Tags count query
?
Require (' common.inc ');
$ip = $REMOTE _addr;
$current =getdate (Time ());
$day = $current ["Mday"];
$query = "SELECT * from Count";
$result =mysql_db_query (' Football ', $query, $link);
while ($row =mysql_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 first". $num;
echo "Visitor";
$query 1= "INSERT into count values (' $ip ', $day, $num)";
Mysql_db_query (' Football ', $query 1, $link);
}
Else
{
echo "You are the first". $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_connect ("localhost", "root", "");
?>

Library is:
Football
Table:
Count
Fields: Ip->char (20)
Day->int (2)
Num->int (8)
This program can be a little modified to become a multi-user register, and can not be false yo!
For personal use only

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.