My database always returns that 1 row is found as a match for the condition that both, the username
and password
(here as passhash
), are correct.
I can just type the correct username
and no password
or a random password
and it will still return that it found 1 row which matches the condition.
$user = $_POST['username'];
$pass = $_POST['password'];
$phash = md5(sha1($pass+"salt123")+"salt123");
$sql = "SELECT * FROM users WHERE username='$user' AND passhash='$phash'";
$result = $conn->query($sql);
$count = mysqli_num_rows($result);
if ($count == 1)
{
echo "Welcome $user, you have successfully logged in!<br />";
}
else
{
echo "username or password is incorrect!";
}