0
Come on, guys, I’ll try to be as enlightening as possible on the question. Next: I have an if Else that is done by a Pdo query, when I type an existing Cpf it does the job properly, until then ok! But when I type in a Cpf that doesn’t exist in the database, it should display Else, where it’s not doing that, someone can help me?
CODE
$acao = (isset($_POST['acao'])) ? $_POST['acao'] : '';
$name = (isset($_POST['name'])) ? $_POST['name'] : '';
$indicated_by = (isset($_POST['indicated_by'])) ? $_POST['indicated_by'] : '';
$password = (isset($_POST['password'])) ? $_POST['password'] : '';
$cpf = (isset($_POST['cpf'])) ? str_replace(array('.','-'), '',
$_POST['cpf']): '';
$telefone = (isset($_POST['telefone'])) ? str_replace(array('(',')','','-'), '', $_POST['telefone']): '';
$data_cadastro = (isset($_POST['data_cadastro'])) ? str_replace(array('.','-'), '', $_POST['data_cadastro']): '';
$password = (isset($_POST['password'])) ? $_POST['password'] : '';
$id_ind = (isset($_POST['id_ind'])) ? $_POST['id_ind'] : '';
$conexao = conexao::getInstance();
$sql = "SELECT * FROM users WHERE cpf = ".$cpf;
$stm = $conexao->prepare($sql);
$stm->execute();
$clientes = $stm->fetchAll(PDO::FETCH_OBJ);
foreach($clientes as $cliente):
if($cliente->cpf === $cpf):
CPF EXISTE
else:
CPF NÃO EXISTE
endif;
endforeach;
Aaaah my friend, agr I realized where I was wrong... being that I saw her tested this way, but I did not notice that I was making a comparison of information in the if. Like... I was doing this in if: if($clients === $Cpf) No need kkkkkkkk, but now it worked. Man thanks so much for the attention there, I think the mental exhaustion was getting in the way of not fixing it. Obg for the help, vlw even.
– Lucas Fiiguer