<?php
include_once '../db/koneksi.php';
session_start();

// pastikan admin login
if (!isset($_SESSION['kode_admin'])) {
    echo "<script>alert('Akses ditolak!'); window.location.replace('".$alamat_admin."keluar.php');</script>";
    exit;
}

if (isset($_GET['id'])) {
    $id = intval($_GET['id']);
    
    $update = mysqli_prepare($koneksi, "UPDATE anggota SET claimed = 1 WHERE id_anggota = ?");
    mysqli_stmt_bind_param($update, "i", $id);
    if (mysqli_stmt_execute($update)) {
        echo json_encode(['status' => 'success']);
    } else {
        echo json_encode(['status' => 'error', 'message' => mysqli_error($koneksi)]);
    }
    mysqli_stmt_close($update);
} else {
    echo json_encode(['status' => 'error', 'message' => "ID tidak ditemukan"]);
}
