Untitled
unknown
plain_text
2 years ago
642 B
11
Indexable
<?php
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 "Nederigi JSON dati.";
exit;
}
if(isset($postData['name']) && isset($postData['age'])) {
echo $postData['name'] . " " . $postData['age'];
} else{
http_response_code(400);
echo "Nederigs datu formats. Nepieciesami dati 'name' un 'age'.";
}
} else{
http_response_code(405);
echo "Atlauts tikai POST pieprasijumi.";
}
?>Editor is loading...
Leave a Comment