<?php
session_start();
include('includes/config.php');


if(!isset($_SESSION['user_id'])){
    header("Location: login_user.php");
    exit();
}

if(isset($_GET['id'])){
    $id_pesanan = intval($_GET['id']);
    $id_user = $_SESSION['user_id'];

    
    $query = "UPDATE pesanan SET status = 'Selesai' WHERE id = '$id_pesanan' AND id_user = '$id_user'";
    
    if(mysqli_query($conn, $query)){
        echo "<script>
                alert('Konfirmasi berhasil! Terima kasih telah berbelanja di Alfateeh Sepatuku.');
                window.location='pesanan_saya.php';
              </script>";
    } else {
        echo "Terjadi kesalahan: " . mysqli_error($conn);
    }
} else {
    header("Location: pesanan_saya.php");
}
?>