OK! I've just started PHP and I'm slowly getting there. However, I've hit a snag with arrays :-/
You see, I have made a login, and an area you can only get in using this pass. At the moment I can only make it so that I use 1 username and 1 password. I tried using arrays but I can't find a way to make it so that one username goes with one password.... I'll explain.
<?
// the variables for the user/pass taken from an exterior form.
$username = $_POST['user'];
$password = $_POST['pass'];
// location of page to go to if username and password match
$url = "!!!!!!!!!!!!!!!!!!ADDRESS!!!!!!!!!!!!!!";
$urlfail =
"!!!!!!!!!!!!!!!!!!ADDRESS!!!!!!!!!!!!!!";
// the arrays for user and pass
$user_array = array("user1","user2","user3","user4","user5");
$pass_array = array("pass1","pass2","pass3","pass4","pass5");
$user_length = count( $user_array );
// this is where it goes screwy, this is wrong!!!
for ( $index=0; $index < $user_length; $index++ )
{
if ( $username == $user_array[$index] && $password == $pass_array[$index] )
{
header("Location: $url");
} else {
header("Location: $urlfail");
}
}
?>
I dont know how to make the second username to work with the second password :-/ any ideas? Thank you for reading :-)