R007S Posted December 7, 2008 Share Posted December 7, 2008 Hey, I just created a register&login system (with a lill help of a tutorial made in 2004), but i'm having some issues when trying to Login. The register script works perfectly, it creates successfully a new account into the database, but when I try to Login it says that the password is wrong, instead of saying that the password is correct. I tried to figure out what the problem is.. but i can't get track of this. I think the problem is here: # Retrieve password from result, strip slashes $dbarray = mysql_fetch_array($result); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); # Validate that password is correct if ($password == $dbarray['password']) { return 0; // Sucess! usrname and pw confirmed } else { return 2; // Indicates password failure } Well, i attached the entire script so you could figure out. Thanks! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/135920-login-and-register-script-using-mysql-and-php/ Share on other sites More sharing options...
peranha Posted December 7, 2008 Share Posted December 7, 2008 Try this and see what you get. are the passwords encrypted? # Retrieve password from result, strip slashes $dbarray = mysql_fetch_array($result); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); echo "password is" . $password . "<br />; echo "dbpassword is" . $dbarray['password']; # Validate that password is correct if ($password == $dbarray['password']) { return 0; // Sucess! usrname and pw confirmed } else { return 2; // Indicates password failure } Link to comment https://forums.phpfreaks.com/topic/135920-login-and-register-script-using-mysql-and-php/#findComment-708575 Share on other sites More sharing options...
R007S Posted December 7, 2008 Author Share Posted December 7, 2008 That don't seem to work. Yes, passwords are encrypted (md5) Please download de code.zip and look for any bug, if you have time. Thanks! Link to comment https://forums.phpfreaks.com/topic/135920-login-and-register-script-using-mysql-and-php/#findComment-708638 Share on other sites More sharing options...
php.ajax.coder Posted December 9, 2008 Share Posted December 9, 2008 Use the md5() function to encrypt the input and then compare the two eg. md5("password") == STORED_PASSWORD Link to comment https://forums.phpfreaks.com/topic/135920-login-and-register-script-using-mysql-and-php/#findComment-710769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.