日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

php mysql ip_使用php和mysql有效禁止IP?

發布時間:2024/3/26 数据库 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php mysql ip_使用php和mysql有效禁止IP? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

CREATE TABLE `banned_ip` (

`id` INT( 25 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`ip` VARCHAR( 25 ) NOT NULL ,

`reason` TEXT NOT NULL )config.php文件

// config

$config['host'] = "localhost"; // host name of your mysql server

$config['user'] = "username"; // your mysql username

$config['pass'] = "password"; // your mysql password

$config['db'] = "database"; // the database your table is in.

// the @ sign is an error supressor, meaning we can use our own error messages, this connects and selects db

@mysql_connect("$config[host]","$config[user]","$config[pass]")

or die("There was an error connecting to the database, MySql said:
".mysql_error()."");

@mysql_select_db("$config[db]")

or die("There was an error connecting to the database, MySql said:
".mysql_error()."");

?>Ban.php

include("connect.php");

$ip = $_SERVER['REMOTE_ADDR'];

$find_ip = mysql_query("SELECT * FROM banned_ip WHERE ip='$ip'");

$ban = mysql_fetch_array($find_ip);

if($ip == $ban['ip']){

die("You are banned from this site!");

else {

echo "Your Were not Banned";

$sql = "INSERT INTO user(ip) VALUES('$ip')";

}

?>我正在做的是檢查我的數據庫的IP,如果它被禁止或不。如果沒有被禁止,向他顯示消息“你沒有被禁止”并禁止他。

將他的IP存儲在數據庫中。然后,如果他再次來到現場,將會顯示“你被禁止從這個網站!”

通過這我給每個ip只有一次訪問我的內容。這個劇本足夠嗎?這個腳本不適合我。這不是禁止我的IP,而是一直向我展示我的內容。

總結

以上是生活随笔為你收集整理的php mysql ip_使用php和mysql有效禁止IP?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。