Jump to content

[SOLVED] Login problem using md5


nuttycoder

Recommended Posts

Hi I have a login script and I can log in no problem but the passwords are not encrypted If I change the

password to be encrypted using md5 like this:

 

$password = md5($_POST['password']); 

 

Then I can no longer log in any idea whats wrong?

 

The full login script

 

 

if (isset($_POST['login'])) {
   
   $username = $_POST['username'];
   $password = md5($_POST['password']);

   // check if the user id and password combination exist in database
   $sql = "SELECT username, password FROM members WHERE username = '$username' AND password = '$password'";
   $result = mysql_query($sql) or die('Query failed. ' . mysql_error());

   if (mysql_num_rows($result) == 1) {
      // the user id and password match,
      // set the session
      
 session_register('username');
 session_register('password');

      
   } else {
      $errorMessage = 'Sorry, wrong user name or password';
   }

  
}

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/66206-solved-login-problem-using-md5/
Share on other sites

its strange I removed the members table and rebuilt it and had the password set to char but its been created using varchar

 

does this make a diffrence with passwords?

 

I can login now thanks very much I really din't want to have passwords that were not encrypted not  good security

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.