0
Good night,
I am learning PHP PDO, and I am 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 creates a session. until that point is ok, my problem is when you put wrong password or wrong email, I made a condition to check but it is not working, when I put the wrong password shows the wrong password message but when I put the wrong email it shows the same wrong password message, someone could give me a light please I’m already about three days into it and I can’t get out of the login page.
follows 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.
Do the following, put a var_dump($validar_client) below $validar_client = .. , and checks if $validar_client['EMAIL_USUARIO'] is actually coming with the value 0
– Leandro