I want to restrict a user by the number of attempts he makes, but I am not sure if to do it with javascript or php..and how exactly. (How do I save data between the same form page request. Is it by using a global variable or is it best by using a session?); Also, how can I ban people by their ip?
5条回答 默认 最新
- doubu8643 2011-10-19 15:33关注
Do it by PHP.
Do a MySQL table
attemptLog
+------+------+------+ | id | ip | date | +------+------+------+
Every time a login attempt fail you add the IP to
attemptLog
. To log in you need a correct username and password (ofc) AND max ie 10 login attempts the last 24h.To do that you can run
SELECT count(ip) AS loginAttempts FROM attemptLog WHERE ip = $_SERVER['REMOTE_ADDR'] AND date < $today - 24h
then check ifloginAttempts
is more then 10.Banning
To ban a user you can save their IP and check if it isset, if it is set show "You are banned", else show the normal page.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 数值计算均差系数编程
- ¥15 redis-full-check比较 两个集群的数据出错
- ¥15 Matlab编程问题
- ¥15 训练的多模态特征融合模型准确度很低怎么办
- ¥15 kylin启动报错log4j类冲突
- ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
- ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
- ¥15 onvif+openssl,vs2022编译openssl64
- ¥15 iOS 自定义输入法-第三方输入法
- ¥15 很想要一个很好的答案或提示