Hello, I happen to have the following:
$("#frmAcceso").on('submit',function(e)
{
e.preventDefault();
logina=$("#logina").val();
clavea=$("#clavea").val();
if ((logina!="") && (clavea !=""))
{
$.post("../Ajax/usuario.php?op=verificar",
{"logina":logina,"clavea":clavea},
function(data)
{
alert(data.length);
alert(data);
if ((rpsta=="null") || (rpsta==null))
{
//$(location).attr("href","Categoria.php");
bootbox.alert("Usuario y/o Password incorrectos");
}
else
{
//bootbox.alert("Usuario y/o Password incorrectos");
$(location).attr("href","Categoria.php");
}
});
}
else
{
$("#logina").focus();
swal('Oops...','Proporcione todos los datos','error');
}
})
and a php method that does the following
case 'verificar':
$logina=$_POST['logina'];
$clavea=$_POST['clavea'];
$clavehash=hash("SHA256",$clavea);
$rspta=$usuario->verificar($logina, $clavehash);
$fetch=$rspta->fetch_object();
if(isset($fetch))
{
$_SESSION['idUsuario']=$fetch->idUsuario;
$_SESSION['Nombre']=$fetch->Nombre;
$_SESSION['Imagen']=$fetch->Imagen;
$_SESSION['Login']=$fetch->Login;
}
echo json_encode($fetch);
break;
Now what the check function does is to see if the user is registered in the database.
public function verificar($login,$clave)
{
$sql="SELECT * FROM Usuario WHERE Login='$login' AND clave='$clave' AND Condicion='1'";
return EjecutarConsulta($sql);
}
Now the problem is that when valid if the query returns a data
if ((logina!="") && (clavea !=""))
{
$.post("../Ajax/usuario.php?op=verificar",
{"logina":logina,"clavea":clavea},
function(data)
{
alert(data.length);
alert(data);
if ((rpsta=="null") || (rpsta==null))
{
//$(location).attr("href","Categoria.php");
bootbox.alert("Usuario y/o Password incorrectos");
}
else
{
//bootbox.alert("Usuario y/o Password incorrectos");
$(location).attr("href","Categoria.php");
}
});
}
else
{
$("#logina").focus();
swal('Oops...','Proporcione todos los datos','error');
}
Even if I return null, it directs me to the page of category.php
I commented that the page I have mounted on a server nas DS216J personal
Thanks a lot for the help