<?php
session_start();
require_once("auth/db.php");

if (!isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) {
    header("Location: admin-login.html");
    exit();
}

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['email']) && isset($_POST['status'])) {
    $email = $_POST['email'];
    $status = $_POST['status'];

    $stmt = $conn->prepare("UPDATE users SET kyc_status = ? WHERE email = ?");
    $stmt->bind_param("ss", $status, $email);

    if ($stmt->execute()) {
        header("Location: admindashboard.php");
        exit();
    } else {
        echo "Error updating KYC status.";
    }
} else {
    echo "Invalid request.";
}
?>