<?php
$jsonFile = 'blood_donors.json';

$data = json_decode(file_get_contents('php://input'), true);

if ($data) {
    if (file_put_contents($jsonFile, json_encode($data, JSON_PRETTY_PRINT))) {
        echo json_encode(["status" => "success", "message" => "Donors updated successfully"]);
    } else {
        echo json_encode(["status" => "failed", "message" => "Failed to save donor data"]);
    }
} else {
    echo json_encode(["status" => "failed", "message" => "No data received"]);
}
?>
