?
Solved

Why isn't this working?

Posted on 2006-10-29
2
Medium Priority
?
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
cheetahshrk earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 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