0
我有一個file.php並在函數中。 Javascript端,我使用Ajax。在PHP文件中調用函數並傳遞JavaScript變量
$.ajax({
type: "POST",
url: "file.php",
data: {param1: params1, param2: params2...},
complete: function(data){
/* code */
}
});
現在在文件file.php中存在函數login。我的問題我怎樣才能調用函數登錄?謝謝。
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];
}