Alright? I'm hoping that when I lose focus, the login field goes to the bank and looks for an equal login. If there is, it means that the guy has to use another and for that the return must be a mistake. If there is not a login like his, nothing happens and he continues to register at will.
My js code is:
function checalogin() {
$.ajax({
url: 'ajax-insere.php?login=' + $('input[name=login]').val(),
type: 'GET',
});
}
And the php code is:
if(isset($_GET['login']) && ($_GET['login'] != '')) {
$txtLogin = $_GET['login'];
$checa_login = 'SELECT * FROM usuarios WHERE login LIKE "' . $txtLogin . '"';
//echo $checa_login;
$resposta = mysql_query($checa_login) or die(mysql_error());
$value = mysql_fetch_assoc($resposta);
if ($value['login'] == $txtLogin) {
header('Location:visualiza.php?loginExiste=1');
}
}
Notice that the header returns with loginExiste = 1. I created a condition in php that:
if(isset($_GET['loginExiste']) && $_GET['loginExiste'] == 1) {
echo '<script>'.
'Materialize.toast('Já existe um login igual a esse. Tente algodiferente.', 7000);'.
'</script>';
}
However, when you lose focus, that is, onBlur, nothing happens. What am I doing wrong?
Thank you!