0
I have a code to register the user on my site, he sees that the user is already registered and does not enter again in 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>";
Make a select before giving the Insert, see if the email he tried to register already exists in the bank, if the return is true you inform the user that the email already exists...
– Darlei Fernando Zillmer
I tried, but it still won’t go
– Maria
Some field is key Unique, email for example.
– rray
And how I change that?
– Maria
How do you see it? /Where is the part of the code that he sees that the user is already registered?
– user60252
Guys, thank you for your attention, but I think I solved it. I’ll post the answer for you to see and if there’s anything wrong, if possible, let me know.
– Maria