Page 1 of 1

What is wrong about my code?

Posted: Tue Mar 23, 2010 10:03 am
by gaddyf
I am trying to write a php code with IP's so that my server will let me connected on my admin if and only if my IP's are the same as in my codes. Here is the code i am using:

<?php
// only local requests
if ($_SERVER['REMOTE_ADDR'] !== '99.19.32.053' || $_SERVER['REMOTE_ADDR'] !== '99.19.32.053' ) die(header("Location: /"));
?>

When I use the above php code with one IP, it works fine but when i use the below, adding an additional ip, it gives me the error

<?php
// only local requests
if ($_SERVER['REMOTE_ADDR'] !== '99.19.32.053','99.104.10.003' || $_SERVER['REMOTE_ADDR'] !== '99.19.32.053','99.104.10.003' ) die(header("Location: /"));
?>

error given:

Parse error: syntax error, unexpected ',' in /home01/maliqu/public_html/admin/home.php on line 24

So how can i correct my code to have it works from 2 different ip's locations?

Re: What is wrong about my code?

Posted: Tue Mar 23, 2010 10:57 am
by AbraCadaver
You did it correctly the first time. What makes you think you can just add a comma and an IP and it will work? And why are you adding the same IPs in again?

Re: What is wrong about my code?

Posted: Tue Mar 23, 2010 11:45 am
by gaddyf
Because when i am using this code:

<?php
// only local requests
if ($_SERVER['REMOTE_ADDR'] !== '99.19.32.053' || $_SERVER['REMOTE_ADDR'] !== '99.104.10.003' ) die(header("Location: /"));
?>
It does not connect. So how to make it worth for these two ip's????

Thanks

Re: What is wrong about my code?

Posted: Tue Mar 23, 2010 12:03 pm
by mikosiko
echo $_SERVER['REMOTE_ADDR'] and see what are you getting... proceed from there

Re: What is wrong about my code?

Posted: Wed Mar 24, 2010 1:47 am
by uu31z
elseif?