I have a user registration code on my site, it sees that the user is already registered and does not re-enter the table, but I can not inform the user that the registration already exists.
$sql = 'INSERT INTO usar (campo1, campo2) VALUES (?,?)';
$stmt = $conn->prepare($sql);
if(!$stmt){
echo 'erro na consulta: '. $conn->error .' - '. $conn->error;
}
$var1 = $_POST['campo1'];
$var2 = $_POST['campo2'];
$stmt->bind_param('ss', $var1, $var2);
$stmt->execute();
echo"<script type='text/javascript'>alert('Cadastro realizado com sucesso.');window.location.href='cadastro.php';</script>";