This commit is contained in:
Thanakorn S
2026-02-24 11:18:04 +07:00
parent 42a38760a3
commit 8625652fe7
5 changed files with 80 additions and 7 deletions
+10 -5
View File
@@ -58,14 +58,19 @@ if(!empty($_SESSION["login_company_id"])){
// set up ANSWER
$answer = array("success"=>0, "message"=>"");
if(!isset($_POST['json']))
{
$answer["message"] = "No data receive!";
if (isset($_POST['json'])) {
// Old Method: Data is wrapped in a JSON string
$data = json_decode($_POST['json'], true);
} else if (isset($_POST['otp'])) {
// New Method: Data is sent directly (FormData)
// We check for 'otp' because every request should have one
$data = $_POST;
} else {
// Truly no data received
$answer["message"] = "Request denied: No valid JSON payload or Form Data detected.";
exit(json_encode($answer));
}
$data = json_decode($_POST['json'],true);
// incase logging in
if(!empty($_SESSION["login_company_id"])){