Use the IP address to count the number of visitors! It is limited by days! _php Tutorials

Source: Internet
Author: User
Require (' common.inc ');
$ip = $REMOTE _addr;
$current =getdate (Time ());
$day = $current ["Mday"];
$query = "SELECT * from Count";
$result =mysql (and PHP collocation of the best combination) _db_query (' Football ', $query, $link);
while ($row =mysql (the best combination of PHP collocation) _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 (and PHP collocation of the best combination) _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 (the best combination of PHP collocation) _connect ("localhost", "root", "");
?>

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

http://www.bkjia.com/PHPjc/509062.html www.bkjia.com true http://www.bkjia.com/PHPjc/509062.html techarticle require (' common.inc '); ip=remote_addr; Current=getdate (Time ()); day=current["Mday"]; query= "SELECT * from Count" ; Result=mysql (and PHP collocation of the best combination) _db_query (' Foot ...

  • 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.