Good evening, I have a problem with here, I'm using an ajax code to check if a cpf is already registered without the refresh on the page to not lose the data, and returning a string with a value encrypted in sha1 for comparison and know if there is already a registration with cpf in the database, but ajax can not compare the string, and if I do alert in the result it right up the result variable from php right, I already searched and in American forums said that it was only put $ .trim () but that did not help either, if anyone can help me or suggest something I appreciate. The codes:
Ajax:
function VerificaCPF(strCPF)
{
$.ajax({
type: 'post',
url: 'daoAssociado.php',
data: {action: 'VerificaCPF', cpf: strCPF},
success: function(resultado)
{
if(resultado == '88e9d785061a31f8bae950b8e231f40426b5496c')
{
return false;
}
else if (resultado == '4b2c518cb740685b1b29f477283165b732651f05')
{
return true;
}
}
});
}
php:
if(isset($_POST['action']) && !empty(($_POST['action'])))
{
$action = $_POST['action'];
switch($action)
{
case 'VerificaCPF':
consultarCPF($conectar);
break;
case 'VerificaUsuario':
consultarUsuario($conectar);
break;
}
}
function consultarCPF($conectar)
{
$cpf = sha1($_POST['cpf']);
$queryVerificarCpf = "exec usp_verificarExistenciaCpf @cpf = ?";
$parameterVerificarCpf = array($cpf);
$query_Resultado = sqlsrv_query($conectar, $queryVerificarCpf, $parameterVerificarCpf) or die(header("Location:erronobanco.php"));
$array_Resultado = sqlsrv_fetch_array($query_Resultado);
$totalDeCpf = $array_Resultado['total'];
if($totalDeCpf != 0)
{
echo '88e9d785061a31f8bae950b8e231f40426b5496c';
}
else
{
echo '4b2c518cb740685b1b29f477283165b732651f05';
}
}