0
I’m making a simple login system but I never get a real line where
$sql = "SELECT * FROM $this->table WHERE 'email' = :email AND 'senha' = :senha";
But the email and password are correct, PHP function:
public function logarUsuario(){
try{
$sql = "SELECT * FROM $this->table WHERE 'email' = :email AND 'senha' = :senha";
$stmt = DB::prepare($sql);
$stmt -> bindParam(":email", $this->email, PDO::PARAM_STR);
$stmt -> bindParam(":senha", $this->senha, PDO::PARAM_STR);
$stmt ->execute();
return $stmt->fetch();
echo $stmt->fetch();
}catch (PDOException $e){
echo "Error".$e->getMessage();
}
}
Here is the programming sending the data to the user class:
if (isset($_POST['logar'])):
//Recebe os dados
$email = $_POST['email'];
$senha = md5($_POST['senha']);
//Salva os dados na classe usuario
$user->setEmail($email);
$user->setSenha($senha);
//Tenta logar
if($user->logarUsuario()){
echo"Logado com sucesso";
}else{
echo"Não foi possivel logar";
}
endif;
Summarizing: The data is registered but, it does not return the true search even logging with the right data.