Untitled
unknown
plain_text
a year ago
637 B
6
Indexable
if ($_SERVER['REQUEST_METHOD'] === 'POST') { $postData = json_decode(file_get_contents('php://input'), true); if ($postData === null && json_last_error() !== JSON_ERROR_NONE) { http_response_code(400); echo "Nederīgi JSON dati." exit; } if (isset($postData['name']) && isset($postData['age'])) { echo $postData['name'] . " " . $postData['age']; } else { http_response_code(400); echo "Nederīgs datu formāts. Nepieciešami dati 'name' un 'age'."; } } else { http_response_code(405); echo "Atļauts tikai POST pieprasījumi."; }
Editor is loading...
Leave a Comment