"JPinkman", "password" => "123456", "name" => "Jesse", "surname" => "Pinkman");
$users[] = array("username" => "WWhite", "password" => "123456", "name" => "Walter", "surname" => "White");
$users[] = array("username" => "SGoodman", "password" => "123456", "name" => "Saul", "surname" => "Goodman");
$users[] = array("username" => "GFring", "password" => "123456", "name" => "Gustavo", "surname" => "Fring");
while(list($key, $val) = each($users)) {
if($val["username"] == $_POST["username"] and $val["password"] == $_POST["password"]) {
return $val;
}
}
return false;
}
if(isset($_POST["username"]) and isset($_POST["password"]) and !empty($_POST["username"]) and !empty($_POST["password"])) {
$user = checkUser();
if(!empty($user)) {
echo "Welcome " . $user["name"] . ".
";
}
else {
echo "Incorrect username or password. Please check your details and try again.
";
authForm();
}
}
else
authForm();
?>