Tuesday, 15 February 2011

php - Comparing mysql password hashes using query row returning 0 (not working) -


I am creating a login system for my website using a MySQL database.

When the user registers, it saves the database using this password:

  $ password = hash ("sha512", "somesalt". $ Password. "Morseet" );  

Then when I login, I compare the password of the password in the database using the same hash function.

I use this to compare the database:

  $ query = mysql_query ("Select from user where password = '$ password' and email = ' $ Email '", $ connection); $ Rows = mysql_num_rows ($ query); If ($ rows == 1) {// do login stuff}  

but rows always return to 0. When I remove the hash function from both registers and logins, it logs properly, what is wrong?

In the case of someone's thinking, I am using my scheme as a side note, but the database version of my webhosting is out of date. They are using 5.2. I do believe.

I forgot to make sure that I checked to ensure that the database has been viewed in these photos (like images can not be embedded). P>

What is the length of your password field in the database << p />

Due to the reason I think the length of the hashead password is very long and when you save the database part or it is removed ...

Then when you compare, you get 0 row. .


No comments:

Post a Comment