<?php header('Content-Type: application/json'); 
include '../koneksi.php'; // Titik dua kali artinya naik satu folder ke atas
// Ambil input JSON mentah dari Android $json = file_get_contents('php://input'); $data = json_decode($json, true);
if (empty($data)) { echo json_encode(["status" => false, "message" => "Data kosong"]); exit; }
$success_count = 0;
foreach ($data as $item) { $id_wali   = $item['id_wali'] ?? 1; $nama      = $item['nama_anak'] ?? ''; $nis       = $item['nis_nisn'] ?? ''; $kelas     = $item['kelas'] ?? ''; $jk        = $item['jenis_kelamin'] ?? '';
if (!empty($nama)) {
    $sql = "INSERT INTO anak_asuh (id_wali, nama_anak, nis_nisn, kelas, jenis_kelamin, status) 
            VALUES ('$id_wali', '$nama', '$nis', '$kelas', '$jk', 'Aktif')";
    if (mysqli_query($koneksi, $sql)) {
        $success_count++;
    }
}
}
echo json_encode(["status" => true, "message" => "Berhasil mengimpor $success_count siswa"]); ?>