<?php
require_once __DIR__ . "/../config/db.php";

$id = (int)($_GET["id"] ?? 0);

// ambil status sekarang
$q = $conn->query("SELECT status FROM resi WHERE id = $id");
$data = $q->fetch_assoc();

if ($data) {
    $newStatus = ($data["status"] === "valid") ? "invalid" : "valid";

    $conn->query("UPDATE resi SET status='$newStatus' WHERE id=$id");
}

// balik lagi ke halaman resi
header("Location: resi.php");
exit;