Jump to content

Login Code Issue


csmcgoo

Recommended Posts

I have a pretty basic PHP log in code connected to a database of register users. However, it's not allowing any users to enter? Could someone please review the code and let me know if you find any errors?

 

	
//Create query
$qry="SELECT * FROM customers WHERE username='$login' AND password='".md5($_POST['password'])."'";

$result=mysql_query($qry);

//Check whether the query was successful or not
if($result) {
	if(mysql_num_rows($result) == 1) {
		//Login Successful
		session_regenerate_id();
		$member = mysql_fetch_assoc($result);
		$_SESSION['SESS_MEMBER_ID'] = $member['id'];
		$_SESSION['SESS_FIRST_NAME'] = $member['fname'];
		$_SESSION['SESS_LAST_NAME'] = $member['lname'];
		session_write_close();
		header("location: key_catalog.php");
		exit();
	}else {
		//Login failed
		header("location: login-failed.php");
		exit();
	}
}else {
	die("Query failed");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/219489-login-code-issue/
Share on other sites

Since the echo is 32 characters, and the stored value is 40 characters, I'd venture a guess that it's a hashing method mismatch. More specifically, I'd bet that the value is inserted into the database with an SHA1 hash, in which case you'd need to use the same hashing algorithm to compare it.

Link to comment
https://forums.phpfreaks.com/topic/219489-login-code-issue/#findComment-1138060
Share on other sites

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.