Function doesn't return correct value. I think something wrong with my code. Please help...
$LName = textbox = username
$LPass = textbox = password
database
user_id int primary key not null auto_increment,
username varchar(15) not null,
password varchar(15) not null, .........
function LogInFx($LName,$LPass)
{
$sql = "select * from member where username = '$LName'";
$res = mysql_query($sql) or die ("Cannot select from member database");
$MyStatus = False;
if (mysql_errno() == 0) // no error
{
if (($MyStatus) && (mysql_num_rows($res) == 1)) //check username
$Temp = mysql_fetch_row($res);
if (($Temp[2]) == ($LPass)) //check password
{
$Status = $Temp[1];
return $Status;
}
else
{
$Status = "NOT CORRECT";
return $Status;
}
}
else //error
{
print mysql_error();
}
return $Status;
}
When I type correct username and password according to my sql, the funtion runs to else.... $Status = "NOT CORRECT" instead of returning username.