Basically my "check" system on login checks the username and password of that typed in. If theres no match it should read out a error message and prevent any more attacks. But what I've found out is....if the passwords "hello123" and you type "hello12" it redirects you to the loggedinpage.....which is wrong.
login page extract:
$username = htmlentities($_POST['username']);
$username = mysqli_real_escape_string($mysqli, $username);
$password =mysqli_real_escape_string ($mysqli, $_POST['password']);
$query = mysqli_query($mysqli, "SELECT * FROM Persons WHERE Username = '$username'");
$row = mysqli_fetch_assoc($query);
$numrows = mysqli_num_rows($query);
$dbuser = $row['Username'];
$dbpass = $row['Password'];
$email = $row['Email'];
$_SESSION['login'] = false ;
$salt1 = $dbuser;
$salt2 = $email;
$hash = hash('sha512' , $salt1.$password.$salt2);
$id = $row['PlayerID'];
if( ($username == '') || ($password == '') ) {
$error_string .= '<font color=red>You have left either the username or password field blank!</font>';
$_SESSION['login'] = false ;
}
else if ($numrows == 1)
{
if ($hash == $dbpass)
{
//$error_string .= 'Authentication succeeded';
$_SESSION['login'] = true ;
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
$_SESSION['ID'] = $id;
header("Location: loggedin.php");
} else {
$error_string .= '<font color=red>Authentication failed</font>';
$_SESSION['login'] = false ;
}
}
else
{
$error_string .= '<font color=red>Authentication failed</font>';
$_SESSION['login'] = false ;
}
}
So what I have done is on loggedin.php ive placed now
if (empty($_SESSION['username']) || empty($_SESSION['email']) || empty($_SESSION['ID']) || $_SESSION['login'] = false)
{
session_destroy();
header('location: login.php');
die();
}
So why on earth is login page saying details are correct when there not
Edited by devilsvein, 30 December 2012 - 03:48 PM.












