djw821 Posted March 8, 2008 Share Posted March 8, 2008 I have created two forms one as a registration for which inserts user data into MySQL database and one as a login form to query and match the data for login. The problem I have is that I can't seem to match the user_name and password when I try to use the login form. I am Absolutley certain that I am using the same username and passowrd as I used on the registration form. Here is my code for inserting the data into the MySQL database. $query = "SELECT user_id FROM registration WHERE user_name='$un'"; $result = @mysql_query ($query); // Run The Query. if(mysql_num_rows($result) == 0) { //Make the Query $query = "INSERT INTO registration (first_name, last_name, email, user_name, password) VALUES('$fn', '$ln', '$e', '$un', PASSWORD('$p'))"; $result = @mysql_query($query); // Run the query. Here it is for the login form $query = "SELECT user_id, first_name FROM registration WHERE user_name ='$un' AND password=PASSWORD('$p')"; $result = @mysql_query ($query); $row = mysql_fetch_array ($result, MYSQL_NUM); But I keep getting the message that The username and password do not match those on file and I am certain that I am usign the same ones. Can someone please help me. Quote Link to comment https://forums.phpfreaks.com/topic/95047-i-cant-retrieve-a-matching-password-from-mysql/ Share on other sites More sharing options...
wildteen88 Posted March 8, 2008 Share Posted March 8, 2008 What size is the password field. The MySQL PASSWORD() function returns an encrypted string which is 41 characters long. Make sure your password field datatype is set to VARCHAR and the length is set to atleast 41 bytes or higher. Quote Link to comment https://forums.phpfreaks.com/topic/95047-i-cant-retrieve-a-matching-password-from-mysql/#findComment-486890 Share on other sites More sharing options...
djw821 Posted March 8, 2008 Author Share Posted March 8, 2008 That seemed to work thanks Quote Link to comment https://forums.phpfreaks.com/topic/95047-i-cant-retrieve-a-matching-password-from-mysql/#findComment-486897 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.