What is wrong about my code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaddyf
Forum Newbie
Posts: 14
Joined: Sat Jun 13, 2009 10:09 pm

What is wrong about my code?

Post 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?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: What is wrong about my code?

Post 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?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
gaddyf
Forum Newbie
Posts: 14
Joined: Sat Jun 13, 2009 10:09 pm

Re: What is wrong about my code?

Post 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
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: What is wrong about my code?

Post by mikosiko »

echo $_SERVER['REMOTE_ADDR'] and see what are you getting... proceed from there
uu31z
Forum Newbie
Posts: 3
Joined: Fri Mar 19, 2010 8:44 pm

Re: What is wrong about my code?

Post by uu31z »

elseif?
Post Reply