Jump to content

Recommended Posts

Hi guys,

I have done alot of login scripts in the past, but now i have decided to try a more secure way, using md5 encryption.

I have encrypted the password correctly in the database and now my function keeps returning false.

My login function is part of a class i made. $this->tablename, $this->accountname, $this->usersession and $this->dbconnection are perfectly fine as they have been working when i tried it without encryption.

Why isn't this working?

[code]

  function Login($pass)
  
  {
  
   $password = md5($pass);
  
         $query = "SELECT * FROM `$this->tablename` WHERE `Username` = '$this->accountname' AND `Password` = '$password' ";
           $result = mysql_query($query, $this->dbconnection);
                                                
                
                if (mysql_num_rows($result) > 0)
                     {
                    
                    
                     $this->usersession = $this->accountname;
                     session_register($this->usersession);
  
                          $query = "UPDATE `$this->tablename` SET `Online` = '1' WHERE `Username` = '$this->accountname' LIMIT 1";
                          mysql_query($query, $this->dbconnection);
                                                      
  
                     return true;
                     }
                         else
                         {
                          
                          return false;
                        
                         }
                    

  }

[/code]
Link to comment
https://forums.phpfreaks.com/topic/4862-md5-encryption-problems/
Share on other sites

Well, I don't see anything in your code that would cause a problem, so I would say to echo out your query to verify that it's correct, and also echo out the password that you have in the db and the md5'd password that is being passed into the function to compare them visually.
Link to comment
https://forums.phpfreaks.com/topic/4862-md5-encryption-problems/#findComment-17183
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.