Jump to content


Photo

Simple Logical OR


  • Please log in to reply
2 replies to this topic

#1 barkster

barkster
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 22 March 2006 - 07:17 PM

I'm missing something really simple here. I want to restrict a site from ip other than the two listed. If it doesn't match either of the ip addresses I want to redirect. If I just look at one ip it works but when I tell it can equal either it redirects no matter if the ip is correct. I'm missing something with the || here.

<?php 
$domain = GetHostByName($REMOTE_ADDR); 
//accetable IP addresses 192.168.10.1 or 192.168.10.5
if (($domain <> '192.168.10.1') || ($domain <> '192.168.10.5')) {
    header("Location: Failed.php");
    }
print($domain);
?> 


#2 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 22 March 2006 - 07:33 PM

Try:

<?php
$domain = GetHostByName($REMOTE_ADDR);
//accetable IP addresses 192.168.10.1 or 192.168.10.5
if (($domain = '192.168.10.1') || ($domain = '192.168.10.5')) {
    header("Location: Failed.php");
    }
print($domain);
?>


#3 barkster

barkster
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 22 March 2006 - 07:49 PM

I finally got it to work with

<?php 
$domain = GetHostByName($REMOTE_ADDR); 
if (($domain != '67.76.239.169') and ($domain != '206.54.192.64')) {
    header("Location: Failed.php");
    }
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users