![]() |
Password Hashing
Hey I'm having some problems with hashing passwords into a database and then comparing them to a user input.
Here's my code: PHP Code:
I do manage to hash the password into the database but it doesn't work when the user logs in. Also it doesn't hash the password every time. Sometimes it just enters the password as plain text into the database. Any help would be appreciated. :) |
It seems to me that you are setting the password with encryption into the session here
$_SESSION['password'] = md5($_POST['password']); and then trying to check a variable called password here. if($num != "0" && $password == $row['Password']) { You do this in the register as well. This is the problem. There is no need to store that stuff in the session for now just setting it to the variable would work. Otherwise your logic seems good. |
Thanks that does make sense, however even when I take out the sessions it still doesn't work! It just says says "Username or Password was wrong" although I can't figure out why?! :S
PHP Code:
|
Can anyone help with my problem?
|
The code you posted above does not contain the string "Username or Password was wrong" so we can't see the process leading to that message being displayed.
|
Ah sorry here is my entire code:
PHP Code:
|
| All times are GMT. The time now is 02:07 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0