[Help] Login System

Posts 1–2 of 2 · Page 1 of 1
[Help] Login System
I am building a simple login system, most of the code here is from a toturial I found online, why do I get the incorrect password error??(Password is correct!)
The password Is not encrypted!


Code:
 <?php
 
$Lname = $_POST['Lname'];
$Lpass = $_POST['Lpass'];

 // Connects to your Database 

 mysql_connect("localhost", "root", "") or die(mysql_error()); 

 mysql_select_db("Acc") or die(mysql_error()); 

 // makes sure they filled it in

 	if(!$Lname | ! $Lpass) {

 		die('You did not fill in a required field.');

 	}

 	$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['Lname']."'")or die(mysql_error());
	$checkpass = mysql_query("SELECT * FROM users WHERE password = '".$_POST['Lpass']."'")or die(mysql_error());

 //Gives error if user dosen't exist

 $check2 = mysql_num_rows($check);

 if ($check2 == 0) {

 		die('That user does not exist in our database. <a href=register.htm>Click Here to Register</a>');

 				}


 //gives error if the password is wrong

 	if ($checkpass == $Lpass) 
	
echo "<h1><b>$Lname</b>, you are logged in!</h1> <br /> <a href='/forum/www.google.com'>link</a>";

else 

die('Incorrect password, please try again.');
 

 ?>
I'd appreciate your help.
Check your password, check your database.

die('Incorrect password, please try again.'); only triggers if password is wrong, code seems fine, so Check the password and database, because somewhere along the line, there is a issue with either.

Only real reason.

Follow this
PHP Login Script

To the letter, and check your password again.
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us