gpt4 book ai didi

mysql - 使用 mysql、php 和 html 阻止用户 ip 注册

转载 作者:行者123 更新时间:2023-11-29 13:35:26 26 4
gpt4 key购买 nike

我想知道如何从 ips 的 mysql 数据库表中阻止给定 ips 的列表。例如,我有一个注册表,如果用户的 ip 与 mysql 数据库中的 ip 不同,他应该看到该表单,否则他应该在该页面上看到一条消息“您不允许在此网站上使用 VPN/代理 ip” ”。首先,我如何创建 mysql 表和列,我需要添加哪些属性,以便我可以从 csv 文件导入 ips。

MYSQL

CREATE TABLE IF NOT EXISTS 'blocked_ips'.......

并且不知道如何继续。尝试使用 VARCHAR(15) 在 phpmyadmin 中添加一列,并尝试导入 ips 的 csv 文件,但它不起作用,它只导入 2 行,并且 2 行中仅包含 00

<?php
//check for user ip
$ip = $_SERVER['REMOTE_ADDR'];
compare the ip got from the user with the mysql table column with ips
if the $ip matches with one from the table echo a message on the same page, (no pop-up).
else {
will echo the form below
?>

<DOCTYPE html!>
<head>
<title> Registration</title>
meta
meta
</head>
<body>
<table class="colortext" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%">&nbsp;</td>
<td height="20" width="70%">{advertiser_msg:8921}</td>
</tr>
<tr>
<td>{advertiser_msg:1092} <span class="mandatory">*</span></td>
<td>{USERFIELD}<span id="fg" style="display: none;white-space: nowrap;"></td>
</tr>
</form>
</body>
</html>

我是这方面的菜鸟,请帮忙。

最佳答案

mysql_select_db("your database name")   or die(mysql_error()); 
# Full Text Attempt
$query = mysql_query("SELECT `IP` FROM `your table` WHERE `IP` = '$ip'");
or
$query = mysql_query("SELECT `IP` FROM `database` WHERE `IP` LIKE '%$ip%'");
//chk for banned ip ipaddress

if (mysql_num_rows($query) > 0)
{
echo "<p> You are not allowed to register with proxy VPN </p>";
}

?>

关于mysql - 使用 mysql、php 和 html 阻止用户 ip 注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18811301/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com