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
gaddyf
Forum Newbie
Posts: 14 Joined: Sat Jun 13, 2009 10:09 pm
Post
by gaddyf » Sun Aug 16, 2009 10:43 am
I am trying to add three ip addresses so that if the ip's do not match the one i've entered, they will not see my webpage:
Code: Select all
<?php
// only local requests
if ($_SERVER['REMOTE_ADDR'] !== '99.54.88.685' '55.65.98.006' '64.99.78.136') die(header("Location: /"));
?>
using this, it does not work but using only one ip like below, it works. So how can i make it work on three or more ip's?
Code: Select all
<?php
// only local requests
if ($_SERVER['REMOTE_ADDR'] !== '99.54.88.685') die(header("Location: /"));
?>
Thanks
Last edited by
Benjamin on Sun Aug 16, 2009 1:56 pm, edited 1 time in total.
Reason: Added [code=php] tags.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Sun Aug 16, 2009 10:48 am
You can't do that.
You need to do:
Code: Select all
if($_SERVER['REMOTE_ADDR'] == 'something' || $_SERVER['REMOTE_ADDR'] == 'something else')
Notice the || (or) symbol.
classi4u
Forum Newbie
Posts: 2 Joined: Sun Aug 16, 2009 12:38 pm
Post
by classi4u » Sun Aug 16, 2009 12:43 pm
Also use != instead of !==
Darsi
classi4u.com
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Sun Aug 16, 2009 12:45 pm
It shouldn't make a difference since they're both strings.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sun Aug 16, 2009 1:56 pm
Moved to PHP - Code
gaddyf
Forum Newbie
Posts: 14 Joined: Sat Jun 13, 2009 10:09 pm
Post
by gaddyf » Sun Aug 16, 2009 2:50 pm
jackpf wrote: It shouldn't make a difference since they're both strings.
Thank you for your help.
gaddyf
Forum Newbie
Posts: 14 Joined: Sat Jun 13, 2009 10:09 pm
Post
by gaddyf » Sun Aug 16, 2009 2:51 pm
jackpf wrote: You can't do that.
You need to do:
Code: Select all
if($_SERVER['REMOTE_ADDR'] == 'something' || $_SERVER['REMOTE_ADDR'] == 'something else')
Notice the || (or) symbol.
Thank you man, it works.