SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Bedford, UK
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting and retrieving a password

    Hi All,

    I have a password field to allow a user to log into an admin panel, but I'm having trouble with encryption.

    Currently I am adding in the users manually through phpMyAdmin with the following SQL

    Code:
    insert into table (username, password) 
    values ('adminuser', md5('adminuserpwd'));
    This obvioulsy adds a hashed value into the table. However, when I try and retrieve it for authentication purposes it won't return any rows. What am I doing wrong

    PHP Code:
    $passCheck mysql_query("select password from form_admin where password = md5('".$_POST['password']."')");
        if(
    mysql_num_rows($passCheck) == 0)
        {
        
    $error_msg .= "Your password is invalid";
        } 
    Is there a better way of doing this?

  2. #2
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MD5 returns a 32 character value - is your password field set to 32?
    Lats...


Bookmarks

Posting Permissions

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