Hello, in this code when running it does not respect the ifs, it goes straight through running everything. For example, if the message "This user does not exist" appears, it should simply close. but also the message "Incorrect password" appears.
<?
include "conection.php";
$login = $_POST['login'];
$senha = $_POST['senha'];
$sql = mysqli_query($con, "SELECT * FROM usuarios WHERE login = '$login'");
while($linha = mysqli_fetch_array($sql))
{
$senha_db = $linha['senha'];
}
$cont = mysqli_num_rows($sql);
if($cont == 0)
{
echo "<meta http-equiv='refresh' content='0; url=index.php'>
<script type='text/javascript'>alert('Este usuario não existe')</script>";
}
else
{
if($senha_db != $senha)
{
echo "<meta http-equiv='refresh' content='0; url=index.php'>
<script type='text/javascript'>alert('Senha incorreta')</script>";
}
else
{
session_start();
$_SESSION['login_usuario'] = $login;
$_SESSION['senha_usuario'] = $senha;
header("Location: perfil.php");
}
}
mysqli_close($con);
?>