Click to See Complete Forum and Search --> : PHP, If, Else, Else


scottyrob
10-31-2006, 02:27 PM
Hi there.. I currently have this code


<?php
session_start();

if($_SESSION['User_Type'] == 'leader')
{
header('Location: LeaderMain.php');
}

else
{
header('Location: ExplorerMain.php');
}

?>


I would like it to be - If user type is leader then go to leadermain.php, If user type is explorer go to explorermain.php else go to error.php

The Little Guy
10-31-2006, 02:39 PM
<?php
session_start();

if($_SESSION['User_Type'] == 'leader')
{
header('Location: LeaderMain.php');
}

elseif($_SESSION['User_Type'] == 'explorer')
{
header('Location: ExplorerMain.php');
}

else
{
header('Location: error.php');
}
?>

so_is_this
10-31-2006, 02:43 PM
Or...
<?php
session_start();

switch ($_SESSION['User_Type']):
case 'leader':
header('Location: LeaderMain.php');
break;
case 'explorer':
header('Location: ExplorerMain.php');
break;
default:
header('Location: error.php');
endswitch;
exit;
?>