<?php
session_start();
include 'koneksi.php';

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

if(isset($_POST['upload'])){
    $nama_file = $_FILES['bukti']['name'];
    $tmp = $_FILES['bukti']['tmp_name'];

    /* pastikan folder bukti ada */
    if(!is_dir("bukti")){
        mkdir("bukti", 0755, true);
    }

    move_uploaded_file($tmp, "bukti/" . $nama_file);

    header("Location: checkout.php");
    exit;
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Upload Bukti Pembayaran</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<style>
body{
    font-family: Arial, sans-serif;
    background:#f4f6f9;
    margin:0;
}
.container{
    width:60%;
    margin:50px auto;
}
.box{
    background:white;
    padding:30px;
    border-radius:14px;
    box-shadow:0 4px 10px rgba(0,0,0,0.08);
    text-align:center;
}
.btn{
    margin-top:20px;
    padding:10px 18px;
    color:white;
    border:none;
    border-radius:8px;
    font-weight:bold;
    cursor:pointer;
    text-decoration:none;
    display:inline-block;
}
.upload{
    background:#28a745;
}
.back{
    background:#007bff;
    margin-left:10px;
}
</style>
</head>
<body>

<div class="container">
    <div class="box">
        <h2>📤 Upload Bukti Pembayaran</h2>

        <form method="POST" enctype="multipart/form-data">
            <input type="file" name="bukti" required><br>

            <button type="submit" name="upload" class="btn upload">
                ✅ Upload Bukti
            </button>

            <a href="pembayaran.php" class="btn back">⬅️ Kembali</a>
        </form>
    </div>
</div>

</body>
</html>