Jump to content

Archived

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

barkster

Simple Logical OR

Recommended Posts

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.

[code]
<?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);
?>
[/code]

Share this post


Link to post
Share on other sites
Try:

[code]<?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);
?> [/code]

Share this post


Link to post
Share on other sites
I finally got it to work with

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

Share this post


Link to post
Share on other sites

×

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.