Jump to content

I can't retrieve a matching password from MySQL


djw821

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.