I'm doing 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 schedule 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;
In short: The data is registered, but it does not return the true search even with the right data.