Jump to content

[SOLVED] Checking my Encrypted Password


Northern Flame

Recommended Posts

I am creating a membership program and in my database i have a table that stores the basic user info.

When they login my script checks for username first, and then for the password.

I want it to check for the encrypted password, but whenever I try that it displays my error

message, "Invalid Password!". How do I have the unencrypted password match the encrypted password?

Somewhere once I saw someone say to use "md5($pass)" but that didnt work. Any suggestions?

Link to comment
Share on other sites

What did you use to encrypt the passowrd? If you used md5 (which by the way is a hash, not encryption) you would use something like...

 

<?php

  $uname = trim($_POST['uname']);
  $upass = md5(trim($_POST['upass']));

  $sql = "SELECT uname,upass FROM users WHERE uname = '$uname' && upass = '$upass'";

?>

Link to comment
Share on other sites

Read the mysql manual entry for the PASSWORD function. It is not to be used by client code, it is an internal mysql function.

 

If all your passwords have already been encrypted via PASSWORD() you will have troubles in the future. MySql will not guarantee the algorithms used to create PASSWORDed passowrds will not change over time. Hence, do NOT use it.

 

Use MD5.

 

Then, follow the example I posted above to do your check.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.