<?php include_once 'header.php'; ?>
<form method="POST" action="<?php echo $alamat_website . 'process_kyc'; ?>" enctype="multipart/form-data">
    <?php
    session_start();
    $nama_anggota = $_SESSION['nama_pengguna_anggota'];

    $stmt = $koneksi->prepare("SELECT * FROM anggota WHERE nama_pengguna_anggota = ?");
    $stmt->bind_param("s", $nama_anggota);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result && $result->num_rows > 0) {
        $data = $result->fetch_assoc();
        ?>
        <!-- Judul Form Registrasi KYC -->
<h2 class="text-lg font-bold text-center mb-4">FORM REGISTRASI KYC</h2>

        <!-- Verifikasi Email -->
        <div class="mb-4">
            <label for="email" class="block text-sm font-medium text-gray-700">Email Anda</label>
            <input type="email" id="email" name="email_anggota" value="<?php echo htmlspecialchars($data['email_anggota']); ?>" readonly class="mt-1 block w-full p-2 border border-gray-300 rounded-md bg-gray-200 cursor-not-allowed">
        </div>

        <!-- Verifikasi Nomor Ponsel -->
        <div class="mb-4">
            <label for="phone" class="block text-sm font-medium text-gray-700">Nomor Whatsapp Anda</label>
            <input type="tel" id="phone" name="telepon_anggota" value="<?php echo htmlspecialchars($data['telepon_anggota']); ?>" readonly class="mt-1 block w-full p-2 border border-gray-300 rounded-md bg-gray-200 cursor-not-allowed">
        </div>

        <!-- Unggah Dokumen Identitas -->
        <div class="mb-4">
            <label for="identity_document" class="block text-sm font-medium text-gray-700">Unggah Dokumen Identitas Asli Anda</label>
            <input type="file" id="identity_document" name="identity_document" accept=".jpg, .jpeg, .png, .pdf" required class="mt-1 block w-full p-2 border border-gray-300 rounded-md">
            <p class="text-xs text-gray-500 mt-1">Dokumen yang diterima: JPG, PNG, PDF</p>
        </div>

        <div class="flex justify-center">
            <button type="submit" class="bg-primary text-white py-2 px-4 rounded-lg hover:bg-primary-dark transition duration-300">
                Verifikasi Sekarang
            </button>
        </div>
        </div>
</div>
        <?php 
    } else {
        echo "Data tidak ditemukan.";
    }
    $stmt->close();
    ?>
</form>

<?php include_once 'footer.php'; ?>