0
I’m using this topic as an example of implementation.
It works, gives me the message that there is already a registered email, BUT if I click register it registers anyway, ignoring the message.
I need a way to force the user to type another email again
checkEmail.html
<script language="javascript">
var email = $("#email");
email.blur(function() {
$.ajax({
url: 'verificaEmail.php',
type: 'POST',
data:{"email" : email.val()},
success: function(data) {
console.log(data);
data = $.parseJSON(data);
$("#resposta").text(data.email);
}
});
});
</script>
verificaEmail.php
<?php
if(isset($_POST['email'])){
#Recebe o Email Postado
$emailPostado = $_POST['email'];
$con = mysqli_connect("localhost", "root", "", "outrasintencoes");
$sql = mysqli_query($con, "SELECT * FROM usuarios WHERE email = '{$emailPostado}'") or print mysql_error();
if(mysqli_num_rows($sql)>0)
echo json_encode(array('email' => 'Ja existe um usuario cadastrado com este email'));
else
echo json_encode(array('email' => 'Usuário valido.' ));
}
?>
Tip! It makes it much easier to answer, if you put the reference link just to situate your question, but you also need to put your code to know where the error is
– Cedric S.