Why isn't this working?
Posted on 2006-10-29
I am racking my brain why this doesn't work.... for all I can tell it should. Why doesn't the password section work?
The if $username == $_POST['user'] evaluates true appropriately. The password part, however, does not evaluate properly.
//Read the authentication file into an array
$authfile = file('auth.txt');
// Cycle through each line in file, searching for authntication match
foreach ($authfile as $login)
list($username, $password) = explode(":", $login);
// Remove the newline from the password
$password == trim($password);
if ($username == $_POST['user'] )
if ($password == md5($_POST['pass']))
$authorized = true;
Here is the content of auth.txt: