<?php
include 'koneksi.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $nama_area = trim($_POST['nama_area']);
    if ($nama_area !== '') {
        $stmt = $conn->prepare("INSERT INTO tbl_area (nama_area) VALUES (?)");
        $stmt->bind_param("s", $nama_area);
        $stmt->execute();
        echo json_encode([
            'success' => true,
            'id_area' => $stmt->insert_id,
            'nama_area' => $nama_area
        ]);
    } else {
        echo json_encode(['success' => false, 'message' => 'Nama area tidak boleh kosong.']);
    }
}
