Upload seluruh tugas SIG Point Line dan Polygon
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
require_once 'config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
try {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (!isset($data['owner_status'], $data['area'], $data['coordinates'])) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Missing required fields']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = getDB();
|
||||
$stmt = $db->prepare('INSERT INTO parcels (owner_status, area, coordinates) VALUES (?, ?, ?)');
|
||||
$stmt->execute([
|
||||
$data['owner_status'],
|
||||
(float)$data['area'],
|
||||
json_encode($data['coordinates'])
|
||||
]);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'id' => $db->lastInsertId(),
|
||||
'owner_status' => $data['owner_status'],
|
||||
'area' => (float)$data['area'],
|
||||
'coordinates' => json_encode($data['coordinates'])
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
http_response_code(405);
|
||||
echo json_encode(['error' => 'Method not allowed']);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user