Link to home
Start Free TrialLog in
Avatar of Souled
SouledFlag for Kuwait

asked on

Ban IP's

Hi all,

I had a previous question here before on banning certain IPs and redirect them to another page

I got the following code


<?php
/* put this at the top of your page */
$certain_ips = array('62.215','62.150','195.226','195.39','213.189','213.181','168.187','194.54');
foreach($certain_ips as $ip)
{
 if(substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip)) == $ip)
 {
  header('Location:login.php');
  exit();
 }
else
{
header('Location:chat.php');
exit();
}
}
?>


The IPs shown are the banned IPs in my site. The problem with this code that it bans only the first two IPs but the rest still can access the site normally.

Anyone can fix that plz?

ASKER CERTIFIED SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Diablo84
Diablo84

sorry that last } should not be there
Avatar of Souled

ASKER


I noticed that.
It gave me error when I processed it.

Now its all fine.

Thanks man

no problem :)