Good evening,
I'm learning PHP PDO, and I'm creating a basic system, where I have the login page to check if the user exists, if it exists it redirects to the index page where it creates a session. until that point it is ok, my problem is when you put the wrong password or wrong email, I made a condition to check but it is not working, when I put the wrong password it shows the wrong password message, but when I put the wrong email it shows the same wrong password message, could someone please give me a light please I'm about three days into this and I can not leave the login page.
follow the code:
<?php
session_start();
include "conexao.php";
$cliente_email=$_POST['cliente_email'];
$cliente_senha=$_POST['cliente_senha'];
$pdo=conectar();
$buscar_cliente=$pdo->prepare("SELECT * FROM usuarios WHERE EMAIL_USUARIO=:email AND SENHA_USUARIO=:senha");
$buscar_cliente->bindValue(":email",$cliente_email);
$buscar_cliente->bindValue(":senha",$cliente_senha);
$buscar_cliente->execute();
$validar_cliente = $buscar_cliente->fetch(PDO::FETCH_ASSOC);
if($cliente_email == $validar_cliente['EMAIL_USUARIO'] AND $cliente_senha == $validar_cliente['SENHA_USUARIO']):
$_SESSION['EMAIL_USUARIO'] = $cliente_email;
$_SESSION['SENHA_USUARIO'] = $cliente_senha;
header('location:index.php');
else:
if($validar_cliente['EMAIL_USUARIO'] = 0 ):
unset($_SESSION['EMAIL_USUARIO']);
unset($_SESSION['SENHA_USUARIO']);
header('location:login.php?area=naoemail');
else:
unset($_SESSION['EMAIL_USUARIO']);
unset($_SESSION['SENHA_USUARIO']);
header('location:login.php?area=naosenha');
endif;
endif;
?>
Thank you in advance.