I have a form that works in a modal way for registration / login. The part of the register is working normally. But the login part has a redirect problem ...
I am using this code below for AJAX. I have done a lot of research on everything I read about windows.location, but I do not know how to do it exactly.
AJAX:
function logar(){
$.ajax({
method: "post",
url: "validalogin.php",
data: $("#login-form").serialize(),
success: function(data){
alert(data);
}
});
}
PHP: I make the checks that I think necessary before and after I try to create a session through a result in the bank / data that the user typed ...
if ($result >1) {
session_name('nacional');
session_start();
$_SESSION['cpf']=$cpf;
$_SESSION['senha']=$senha;
header("Location: my_folder/index.php");
}
- NOTE: The header tag is not targeting. Do I have to do something the way the server returns an "ok" for ajax and it changes the targeting? If so how to proceed?
Thanks for listening.