<?php
include 'config.php';

header('Content-Type: application/json');

if (isset($_GET['nis'])) {
    $nis = $conn->real_escape_string($_GET['nis']);
    
    $sql = "SELECT * FROM siswa WHERE nis = '$nis'";
    $result = $conn->query($sql);
    
    if ($result->num_rows > 0) {
        $siswa = $result->fetch_assoc();
        echo json_encode([
            'success' => true,
            'siswa' => $siswa
        ]);
    } else {
        echo json_encode([
            'success' => false,
            'message' => 'Siswa tidak ditemukan'
        ]);
    }
} else {
    echo json_encode([
        'success' => false,
        'message' => 'NIS tidak diberikan'
    ]);
}

$conn->close();
?>