Solved

Why isn't this working?

Posted on 2006-10-29
2
271 Views
Last Modified: 2008-03-06
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']))
                        {
                              echo "AUTHROIZED.";
                              $authorized = true;
                              break;
                        }
                  }
            }            


Here is the content of auth.txt:

test:81dc9bdb52d04dc20036dbd8313ed055
test2:81b073de9370ea873f548e31b8adc081



0
Comment
Question by:DrDamnit
2 Comments
 
LVL 1

Accepted Solution

by:
cheetahshrk earned 500 total points
ID: 17831154
You made an error when you trimmed the password gotten from the file.
$password == trim($password);
should be
$password = trim($password);
0
 
LVL 32

Author Comment

by:DrDamnit
ID: 17831191
Nothing like sending 45 inutes looking for a mistake, and then having another set of eyes find it in 10 minutes! :-) Thanks!
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question