Hi, I am having trouble with this chunk of PHP script:

   <?php
$deny = array("Example IP");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
   header("location: http://www.google.com/");
   exit();
} ?>

It works fine, its just when I try to link to a file that has the $deny var, it wont work. I tried using fopen(); and include();..... I just want it so that I don't have to go to every page of my website just to update a ip address. All I'm saying is that I don't want to have to update every single page of my website, I just want the $deny var in a different script, so that all the pages pull the data of the $deny var from a different file, not each individual page that has the lines of code. If you want to se what made me fail here are samples:

one example:

<?php
$arry = fopen("banned/bannames.php");
if (in_array ($_SERVER['REMOTE_ADDR'], $arry )) {
   header("location: http://www.myurl.com/banned/banned.php");
   exit();
   close_fopen();
}
?>

The bannednames.php file contains this:

<?php
//The $deny var.... This is the var used in all pages, but the IP's are in here
//Not repeated in all pages.
$deny = array("example IP");

?>

I just want it so that I dont have to update all the pages for a single IP, I want it so that I only need to put the IP in the bannames.php instead of every single page. I would be happy if someone helped me out here.

Thanks...

Never mind I got it fixed. I just got the include messed up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.