Jump to content


Md5 Encryption Problems

  • Please log in to reply
2 replies to this topic

#1 Zebadee

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 March 2006 - 07:12 PM

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?

  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;
                          $query = "UPDATE `$this->tablename` SET `Online` = '1' WHERE `Username` = '$this->accountname' LIMIT 1";
                          mysql_query($query, $this->dbconnection); 
                     return true;
                          return false;


#2 hitman6003

  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 13 March 2006 - 11:45 PM

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.

#3 keeB

  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 13 March 2006 - 11:59 PM

$query = "SELECT * FROM `$this->tablename` WHERE `Username` = '$this->accountname' AND `Password` = '$password' ";

$this->tablename and $this->accountname are probably where the problem lies..

Come visit my site to see my latest projects

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users