Hey LookinfreshUK, try the following in place of your current code.
<?PHP
$usernames = array('admin','admin2');
$passwords = array('admin','admin2');
$page = array('index.php','Harts.php');
// Count the amount of users in array.
$count_users = count($usernames);
// Set users found to "0".
$user_found = '0';
// Set username and password variables from $_POST data.
$username = $_POST['username'];
$password = $_POST['password'];
// Check to see if we have a match in usernames
// If we have a match set a variable with the record number
// Update "$user_found" if we find a match
for($u=0; $u<$count_users; $u++) {
if($username == $usernames[$u]) {
$userRecord = $u;
$user_found = '1';
}
}
// If no user is found, login has failed. Re-direct back to login.
if(!$user_found) {
header('Location: login.php?value=fail');
exit;
}
// If usernames don't match, login has failed. Re-direct back to login.
if($usernames[$userRecord] != $username) {
header('Location: login.php?value=fail');
exit;
// If passwords don't match, login has failed. Re-direct back to login.
} else if($passwords[$userRecord] != $password) {
header('Location: login.php?value=fail');
exit;
// If usernames and passwords match, login succeeded. Re-directed to player specific page.
} else {
$_SESSION['username'] = $username;
header("Location: $page[$userRecord]");
exit;
}
?>
Tell me if it works or not bud
Regards, Paul.