Jump to content

[SOLVED] Ban IPs


steviez

Recommended Posts

Hi,

 

I am trying to ban IP addresses on my site by putting all the banned IPs in to a database, When more than one IP is in the databae it wont work. Here is my code so far:

 

<?php
$bans = sql_row("SELECT * FROM bans");
if($bans['ip'] == $_SERVER['REMOTE_ADDR']){
$banned = true;
}

$smarty->assign("your_banned",$lang['banned']);
$smarty->assign("banned",$banned);
$smarty->assign("banned_ip",$banned_ip);
?>

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/83227-solved-ban-ips/
Share on other sites

your code should be something like the following

 

<?php

$bans = sql_row("SELECT * FROM bans where ip='{$_SERVER['REMOTE_ADDR']}'");

if($bans['ip']){

$banned = true;

}

 

$smarty->assign("your_banned",$lang['banned']);

$smarty->assign("banned",$banned);

$smarty->assign("banned_ip",$banned_ip);

?>

Link to comment
https://forums.phpfreaks.com/topic/83227-solved-ban-ips/#findComment-423377
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.