I have a simple sticky login form(user name, password, and confirm password) that uses a session; it is for local network use. I have that form input sent to another page that checks if the user name is in one array, and I need it to check the password against the password for the particular user name entered. This instead of just checking against all of the passwords in the second array. Checking the $user_name works fine: but, checking the password for the user name entered is FALSE no matter what I try.
I thought the basic “check” would look something like this after getting the inputs; I just made up the $names, and $passwords, arrays for now:
[CODE]// Get form input
$user_name = trim($_REQUEST[‘user_name’]);
$password = trim($_REQUEST[‘password’]);
$password_one = trim($_REQUEST[‘password_one’]);
// Arrays to check input against
$names = array(‘Ben’, ‘Wess’, ‘Dave’, ‘Robin’, ‘Sarah’);
$passwords = array(‘Ben’=>”argh”, ‘Wess’=>”fffff”, ‘Dave’=>”harry”,
‘Robin’=>”987654321″, ‘Sarah’=>”trueBlue”);
// Check Form Input
if (!empty($user_name) AND in_array($user_name, $names))
{
if (!empty($password) AND !empty($password_one) AND $password==$password_one AND in_array($password, $passwords[‘$user_name’]))
{
print “You have logged in successfully”;
}
I think I’m doing something wrong on this line:
[CODE]AND in_array($password, $passwords[‘$user_name’])
But I’m relatively new to PHP, and I can’t seem to get it working properly.
Any help would be greatly appreciated, Thank you!