Finally got my code to work, sort of. I'm not sure what I can do to define variable $username/$password without the else in the if/else statement executing. When the page loads it display the message "Oops something went wrong try again!" I realize it's doing this because I was declaring $username/$password to be NULL. I took that part out of the code, but than I get the error message "Undefined variable: username" and now I'm not sure what I can do to avoid both of these errors. Does anyone have any ideas? Thanks in advance.
<html>
<body>
<?php
echo "<form action='oneFile.php' method='post'>";
echo "<table border='0'>";
echo "<tr bgcolor='#cccccc'>";
echo "<td width='150'>Username: </td>";
echo "<td width='20'><input type='text' name='username' size='15'
maxlength='15'></td>";
echo "</tr><tr><tr bgcolor='#cccccc'>";
echo "<td width='150'>Password: </td>";
echo "<td width='20'><input type='password' name='password' size='15'
maxlength='15'></td>";
echo "</tr></tr><tr><td colspan='2' align='center'>
<input type='submit' value='Login'></td>
</tr>
</table>
</form>
</body>
</html>";
?>
<?php
$usernameArr = array( 1 => "elliez",
2 => "greatGuy",
3 => "blogger",
4 => "bob",
5 => "mike",
6 => "jane",
7 => "joe",
8 => "rachel",
9 => "james",
10 => "pizzaman2000");
$passwordArr = array( 1 => "tr789ial",
2 => "abc123",
3 => "23seventeen23",
4 => "12345",
5 => "Password123",
6 => "P@ssword123",
7 => "pass123",
8 => "123pass",
9 => "123P@ssword",
10 => "54321");
$varBool = false;
if(isset($_POST['submit'])){
$username = htmlspecialchars(trim($_POST['username']));
$password = htmlspecialchars(trim($_POST['password']));
trim($username);
trim($password);
}
for ( $i = 1; $i <= 10; $i++){
if ($username == $usernameArr[$i] && $password === $passwordArr[$i]){
$varBool = true;
}
}
If ($varBool){
echo "You have successfully logged in!";
}
else{
echo "Oops something went wrong try again!";
}
?>