PDA

View Full Version : User login.


simon157
04-11-2007, 01:51 PM
Hi

The following is part of some login code I use. It allows a user with a certain username to be taken to a personalised page just for them.

if ($_SESSION['MM_Username'] == "Sevendust") {
header("Location: ******daveowen.php");
} else {
header("Location: " . $MM_redirectLoginSuccess );
}

I have two questions. The first is that it only seems to work if the relevant user enters his username with a capital 'S'. How can I make it accept either upper and lower case.

My second question is how to I add addtional users so that they can be taken to their own unique page. I'm not looking at many. Just another 2 -3 people.

Hope someone can help.

Thanks

Simon

darksidepuffin
04-11-2007, 02:08 PM
1.


if(strtolower($_SESSION["MM_Username"]) == 'sevendust')
{
//redirect
}


2.


if(strtolower($_SESSION["MM_Username"]) == 'sevendust')
{
//redirect
}
elseif(strtolower($_SESSION["MM_Username"]) == 'potatohead')
{
//redirect
}
elseif(strtolower($_SESSION["MM_Username"]) == 'cheeseman')
{
//redirect
}
else
{
//default
}


slightly more optimized:



$username = strtolower($_SESSION["MM_Username"]);

if($username == 'sevendust')
{
//redirect
}
elseif($username == 'potatohead')
{
//redirect
}
elseif($username == 'cheeseman')
{
//redirect
}
else
{
//default
}