0
<?php
class Login{
public function logar($email,$senha){
$connect=new DB;
$connect=$connect->conectar();
$sql="select * from usuarios where email='$email' and senha='$senha' and status='1' limit 1;";
$buscar=mysqli_query($connect,$sql);
$result=mysqli_num_rows($buscar);
if ($result==1) {
$log=1;
$dados=mysqli_fetch_array($buscar);
$_SESSION["email"]=$dados["email"];
$_SESSION["senha"]=$dados["senha"];
$_SESSION["nivel"]=$dados["nivel"];
setcookie("logado",1);
}
if (isset($log)) {
$flash="Logado com sucesso!";
}else{
$flash="Verifique se as informações inseridas estão corretas!";
}
echo $flash;
}
}
?>
Is there something above that makes it impossible for the query to be other than '1'? We assume the following situation: in my database there is an email record:'[email protected]' and password: 'admin' why when executing this code by entering the correct information the answer shown on the screen is "Check that the information entered is correct!"?
The
status
of that user is as 1?– Roberto de Campos
is yes, that same SQL was run in PHP Myadmin
– Victor Antonio
how are the connection data entered? I’ve circled here without class and without logging Function, inserting the connection directly and worked
– user60252
Not because you’re with
limit 1
, thenmysqli_num_rows
will be 0 or 1 always– Guilherme Nascimento