Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to limit the number of logon failures in php

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Most people do not understand the knowledge points of this article "php how to achieve login failure limit", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php how to achieve login failure limit" article.

Php to achieve login failure limit methods: 1, to create a table used to record user login information; 2, to view the record of password errors; 3, under the same IP, the same user in 30 minutes the number of password errors reached the set number of errors, do not allow users to log in.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

PHP implements limit on the number of login failures

Limit on the number of login password errors

The importance of security to every website is self-evident. Among them, login is a place in the website that is more vulnerable to attack, so how can we strengthen the security of the login function?

Let's first take a look at how some well-known websites are done.

Github

Github site the same account in the same IP address in a series of passwords typed a certain number of times, the account will be locked for 30 minutes.

The main reason why Github does this, I think, is mainly based on the following considerations:

Realization idea

Since the login function of so many websites is such a function, then how to achieve it. Next, let's talk about it in detail.

Specific code and table design

User_login_ info table

CREATE TABLE `user_login_ info` (`id` int (10) UNSIGNED PRIMARY KEY AUTO_INCREMENT NOT NULL, `uid` int (10) UNSIGNED NOT NULL, `ipaddr` int (10) UNSIGNED NOT NULL COMMENT 'user login IP', `logintime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT' user login time' `pass_wrong_time_ status` tinyint (10) UNSIGNED NOT NULL COMMENT 'login password error status' COMMENT'0 correct 2 error') ENGINE=InnoDB DEFAULT CHARSET=utf8

User table (user table)

CREATE TABLE `user` (`id` int (10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar (100) NOT NULL COMMENT 'username', `email` varchar (100) NOT NULL, `pass` varchar (255) NOT NULL, `status` tinyint (3) UNSIGNED NOT NULL DEFAULT'1' COMMENT'1 enable 2 disable', PRIMARY key (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report