ajax.php adında bir dosya ve ajax adında bir klasör oluşturun. Tüm ajax isteklerini ajax.php adresine yapın.
ajax.php içeriği;
<?php
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
header("Content-type: application/json; charset=utf-8");
http_response_code(403);
echo StaticFunctions::JsonOutput(array(
'HttpStatusCode' => 403,
'ErrorMessage' => 'Access Denied.'
), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}
if (!isset($_SERVER['HTTP_REFERER'])) {
header("Content-type: application/json; charset=utf-8");
http_response_code(403);
echo StaticFunctions::JsonOutput(array(
'HttpStatusCode' => 403,
'ErrorMessage' => 'Access Denied.'
), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}
$AjaxFile = isset($_POST['ProcessName']) ? $_POST['ProcessName'] : 'blank';
if (!$_POST) {
http_response_code(401);
exit;
}
if (!file_exists('./ajax/' . $AjaxFile . '.php')) {
http_response_code(401);
exit;
}
require_once './ajax/' . $AjaxFile . '.php';Daha sonra formda ProcessName inputuna hangi değeri verdiyseniz ajax klasörünün altında o isimde bir dosya oluşturun. Örneğin BanUser değerini verdiyseniz BanUser.php dosyasını oluşturun. İstek otomatik olarak o dosyaya gelecektir.
Böylece istekleri çok daha kolay yönetebilirsiniz.
Kralsın teşekkür ederim deneyeceğim hemen