I have a file.php and inside a function. Javascript Side, I use Ajax.
$.ajax({
type: "POST",
url: "file.php",
data: {param1: params1, param2: params2...},
complete: function(data){
/* code */
}
});
Now in the file file.php, a function login exists. My question how can I call the function login ? Thanks.
function ft_login($login, $password) {
$u = new KVObject();
$u->collection = "users";
$u->loadFormArray(["login" => $login, "password" => $password]);
if ($u->obj_id == null)
return ["ERROR" => "Bad creditial"];
if ($u->status == "blocked")
return ["ERROR" => "Account need to be activated"];
$token = md5(time());
$_SESSION[$token] = $u->dataObject;
return ["token" => $token, "user" => $u->dataObject];
}