Redirecting a user

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
insane
Forum Newbie
Posts: 5
Joined: Wed Mar 24, 2004 3:56 am

Redirecting a user

Post by insane »

Say for example you have two variables. If their values are both the same then the user must be directed to a certian page and if the variables are not the same then the user must be taken to a diffrent page. I searched the internet for a php script but could'nt actuaualy find anything. Does any one have an idea on what command/script to use?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Code: Select all

<?php
if($var1 === $var2){
    header("Location: page1.php");
    exit;
} else {
    header("Location: page2.php");
    exit;
}
?>
or you could just include/require different php files instead of redirecting.
User avatar
werlop
Forum Commoner
Posts: 68
Joined: Sat Mar 22, 2003 2:50 am
Location: /dev/null

Post by werlop »

Just remember if your gonna use headers to do it, you can't have any script output, even a space, before the header function. That's a common mistake.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

ive got a solution

buy 20 more server

like i said though, i dont understand these problems as i have never suffered from any!?

maybe ive just been lucky so far
Post Reply