Home > Backend Development > PHP Problem > How to achieve how many times each IP is browsed per day in php

How to achieve how many times each IP is browsed per day in php

藏色散人
Release: 2023-03-12 16:00:02
Original
2101 people have browsed it

php method to realize how many times each IP is viewed per day: 1. Create a table through "CREATE TABLE ip_log()"; 2. Set the IP information to be recorded when the user visits, and the initial value of the number of views is 1 ;3. When the number of pages viewed is equal to the set value, the user is not allowed to access.

How to achieve how many times each IP is browsed per day in php

The operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

How to set the daily number of each IP in php views?

Use PHP to limit the number of pages viewed per day per IP

Implementation idea: First, create a table, such as the following

CREATE TABLE ip_log
  (
      ip_log_ip VARCHAR(40),
      ip_log_date DATE,
      ip_log_visits TINYINT(1),
      ip_log_page varchar(255),
      PRIMARY KEY(ip_log_page,ip_log_ip,ip_log_date),
  );
Copy after login

Then, write code to record the IP information when the user visits. The initial value of the number of views is 1.

When the number of pages viewed is equal to the set value, the user is not allowed to access.

Finally you can run a cron table at 00:00 every night to delete all data, such as using truncate

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to achieve how many times each IP is browsed per day in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template