Page 1 of 1

if then header problem

Posted: Wed May 17, 2006 4:24 pm
by bobby9101
I would like to use an if then statement for two header locations.
say i access page hello.php from my ip address 127.0.0.1 then i get sent to index.php
but if i access from any other ip i get sent to goodbye.php

i set them as variables like this:

Code: Select all

$header = 'if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') header("Location: hello.php");';
$header2 = 'header("Location: goodbye.php");';
any ideas on how to make this work?

Posted: Wed May 17, 2006 4:33 pm
by Burrito
on the right track you are:

try this you should:

Code: Select all

if($_SERVER['REMOTE_ADDR'] == "127.0.0.1")
{
   header("Location: hello.php");
   exit;
}
else
{
   header("Location: goodbye.php");
   exit;
}

Posted: Wed May 17, 2006 4:39 pm
by bobby9101
THANK YOU
i am a total newbie i am suprised i got that far
could have never done it without you