Hello all,
I've got a web page I'm making just for learning only. Today I decided to play with some IP address comparisons, for example making it viewable to only the two computers on my home network (192.168 range).
Eventually I might add the ability to see the sight from my work IP address.
Anyways, I've only been learning php for a few days and it's been a LONG time since I've programmed in Java or C++. Thus, I've forgotten some of the basics.
Can someone please advise me or give me some direction on why this is returning true?
CODE
<?php
include ('action.php');
$ip=$_SERVER['REMOTE_ADDR'];
$home = '127.0.0.1';
if(($ip != $home)||($ip != '192.168.0.2')){
//redirect_to_google();
echo ('did it');
}
?>
Basically, it pulls the IP adress of the viewer of the website and if it's not 192.168.0.2 (my other computer) or the one I'm on now it should redirect to google.
It works fine with only 1 IP address listed ie (if ($ip ==$home)) or similar. So there's some problem with how i'm setting up the OR/comparison.
Ccan someone jar my memory?
EDIT: I should clarify. The rest of the webpage is under this code. All this does is echos 'did it' on top of the webpage if for some reason my IP isnt equal to $home or .0.2.
This post has been edited by chrisd234: 14 Jun, 2008 - 07:32 AM