I'm doing a search in my DB to check for email, avoiding the registration of it again, but I'm having a problem with the return, the script below sends and treats the return.
if (sender.getFieldName() == 'Email') {
if (sender.getValue()) {
var emailExist = false;
$.ajax({
type: 'GET',
url: 'AjaxBasedValidation.php',
data: {
checkEmail: sender.getValue()
},
async: false,
dataType: 'json',
success: function(dataResult) {
emailExist = dataResult;
}
});
editors['Email']
.setState(emailExist ? 'warning' : 'success')
.setHint(emailExist ? 'E-mail ' + sender.getValue() + ' já está cadastrado' : null);
} else {
editors['Email']
.setState('normal')
.setHint(null);
}
}
The code that checks in the DB:
#Recebe o Email Postado $emailPostado = $_GET['checkEmail']; #Conecta banco de dados $con = mysqli_connect(".", "", "", ""); $sql = mysqli_query($con, "SELECT * FROM 'usuarios' WHERE 'Email' = '{$emailPostado}'") or print mysql_error(); if($rcQuery == true){ die('{"dataResult" : 0"}'); } else { die('{"dataResult" : 1"}'); }
All emails that I am reporting the script are saying they are already registered.