I need to fill in an email in the email field, search the database and return a message telling me if this email is already registered in the database. We developed jQuery + PHP according to the answers posted in a question that we sent, but in the same way, I could not elaborate.
VerifyEmail.html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><inputtype='text'id='email'><divid='resposta'></div><scriptlanguage="javascript">
var email = $("#email");
email.change(function() {
$.ajax({
url: 'verificaEmail.php',
type: 'POST',
data: email.val(),
dataType: 'json',
success: function(data) {
console.log(data);
if (data.email) { // se existir
$("#resposta").append('Ja existe um usuario cadastrado com este email');
}
},
error: function() {
$("#resultado").show().fadeOut(5000);
}
});
});
</script>
VerifyEmail.php
<?php
if ( isset($_POST['email']) ) {
$vEmail = $_POST['email'];
if ( $vEmail == "[email protected]" ) {
return true;
} else {
return false;
}
}
?>
The case is, that when running, does not return anything ... Nor does the console return errors ... Can anyone help me? Thanks!