Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    usernames using md5 ???

    i have recently been trying to create a site that uses an "account" system.

    For extra care i have decided to store user passwords encrypted using the one way encryption md5!

    now... i would think that this would be easy as i would get the password md5 it and then put it in teh database...

    thats fine... all goes in but when i pull the md5 encrypted password out of the database to compare it with the users submiied password (via the login form) the 2 md5ed numbers dont match.

    so... heres the code im using...

    $password = md5($password);

    $query = "SELECT password FROM table WHERE username=$username";
    $result = mysql_query($query);

    $member = mysql_fetch_array($result);

    if ($password == $member['password'])
    {

    echo "login accepted";
    }
    else
    {
    echo "login failed";
    }


    thats just a quick example but thats basically what its using... always it comes back as "login failed"

    ????????

    any help appreciated.... thanks in advance

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    $query = "SELECT password FROM table WHERE username=$username";
    should be

    $query = "SELECT password FROM table WHERE username='$username'";

    so I expect you are not getting an array returned in the first place

    try that and also use mysql_error() to give you a clue whats going wrong..

    $result = mysql_query($query)or die(mysql_error());
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •