Jump to content

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

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.