For this you will need to use ajax and preferably jQuery:
JS:
$(document).ready(function () {
// A cada tecla precionada executo o AJAX
$("#id_do_campo_de_texto_onde_sera_inserido_o_email").keydown(function () {
var request = $.ajax({
url: "pagina_que_fara_a_busca_no_banco.php",
method: "POST",
data: {email: $("#id_do_campo_de_texto_onde_sera_inserido_o_email").val()}
});
request.done(function (data) {
// data = será o retorno da página "pagina_que_fara_a_busca_no_banco.php"
if(data == 1){
// existe
}else{
// não existe
}
});
request.fail(function () {
console.log("OPS... ocorreu um erro na requisição");
});
});
});
PHP: pagina_que_fara_a_busca_no_banco.php
<?php
//coloque seu select aqui e verifique se o email existe
$sql = "SELECT... WHERE campo_email_banco like %".$_POST['email']."%"
$email = "execute aqui a query";
if($email != ""){
echo "1";
}else{
echo "2";
}
?>
In the PHP file you use the search method you prefer, as I think very personal did not write the code straight (I use class for example)... But the important thing is to understand the logic.
Create a Rest service that seeks to validate the email while completing the registration.
– Elton Tomas Laice
It doesn’t make sense to be in the login, it wouldn’t be in the register?
– user94336