Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Apr 2005
    Location
    London
    Posts
    4
    Member #
    9609
    Hey

    I am having a bit of trouble in implementing a md5() hashing function for username/password logins.

    ======================================
    $query = "SELECT password FROM players WHERE email='$form_email';";
    $returnedpass = mysql_query($query);
    $enteredpass = md5($form_pass);
    $comparison = strcmp($returnedpass, $enteredpass);
    if ($comparison = 0)
    {
    echo "Logged in.";
    } else {
    die("You could not be authenticated.");
    }
    ======================================

    I used the strcmp function and it interestingly produces 1 when echo-ed. Also if $returnedpass (md5 hash of password stored in DB) is echo-ed it outputs "Resource id #3".

    Also the == and === operators didn't work in comparing the strings directly.


    Thanks in advance for any help,
    William

  2.  

  3. #2
    Senior Member
    Join Date
    Aug 2003
    Posts
    444
    Member #
    2801
    Hi,

    This is the expected behaviour! Read more about it at http://uk2.php.net/manual/en/function.mysql-query.php . In particular, this sentence is what you're looking for:

    "The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data."

    Hope this helps...
    eKstreme
    eKstreme.com - Free website tools!
    fontfox - free fonts Hand-picked quality fonts.

  4. #3
    Junior Member
    Join Date
    Apr 2005
    Location
    London
    Posts
    4
    Member #
    9609
    Cheers. Got it sorted now.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:00 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com