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?
What is wrong about my code?
Moderator: General Moderators
- 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?
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.
Re: What is wrong about my code?
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
<?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?
echo $_SERVER['REMOTE_ADDR'] and see what are you getting... proceed from there
Re: What is wrong about my code?
elseif?