-3
Guys, the thing is, I made this code and when I check with a user that does not exist in the bank, I end up returning the message that the user exists and does not write.
In this case here, I have to check if there is already a user with name, Cpf or login already registered in the bank.
I’ve tried it in other ways but it didn’t give me the right result either.
<?php
include ("conectarbanco.php");
$nome=$_POST["nome"];
$cpf=$_POST["cpf"];
$email=$_POST["email"];
$telefone=$_POST["telefone"];
$login=$_POST["login"];
$senha=$_POST["senha"];
$verifica_banco=mysqli_query($conexao,"SELECT *FROM petianos LIMIT 1");
if(mysqli_num_rows($verifica_banco) > 0){
echo "<script language='javascript' type='text/javascript'>
alert('Usuário já cadastrado com esse CPF ou Nome ou Login!');
window.location.href='cadpetiano.html'
</script>";
}else{
mysqli_query($conexao,"INSERT INTO petianos(nome,cpf,email,telefone,login,senha) values ('$nome','$cpf','$email','$telefone','$login','$senha')");
echo "<script language='javascript' type='text/javascript'>
alert('Petiano cadastrado com sucesso!');
window.location.href='cadpetiano.html'
</script>";
}
?>
Your question is phrased quite vaguely. The error returns possibly because the CPF field in the database is unique. The validation aims to ensure the consistency of the data that will be submitted in the form. It is recommended that these data be processed before the Insert in the database.
– Renato Nascimento
*FROM
in the select and why you check if it exists in the users table, but insert in the table petianos?– Woss
HEEEEEEEEEEEEELP
– Vitor Matheus