File "withdraw.php"

Full Path: /home/quiczmwg/lightspringdigitals.com/dashboard-20260114051212/include/withdraw.php
File size: 4.51 KB
MIME-type: text/x-php
Charset: utf-8

<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

include "./include/head.php";
include "sidebar.php";
include "./include/navbar.php";

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

$success = $error = "";

// Fetch user's assigned code from DB (assuming stored in column `user_code`)
$userid = $_SESSION['userid'];
$userResult = mysqli_query($conn, "SELECT user_code FROM user_login WHERE userid = '$userid'");
$userData = mysqli_fetch_assoc($userResult);
$assigned_code = trim($userData['user_code']);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $entered_code = trim($_POST['verify_code']);

    if ($entered_code === $assigned_code) {
        $success = "✅ Withdrawal Successful!";
    } else {
        $error = "❌ Invalid Code. Please try again.";
    }
}
?>

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

<style>
    body {
        background: #f4f6fa;
        font-family: 'Poppins', sans-serif;
    }

    /* Preloader */
    #preloader {
        position: fixed;
        top: 0; left: 0;
        width: 100%; height: 100%;
        background: #fff;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        transition: opacity 0.5s ease;
    }

    .spinner {
        width: 70px;
        height: 70px;
        border: 6px solid #ddd;
        border-top: 6px solid #764ba2;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    .withdrawal-card {
        background: #fff;
        border-radius: 20px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
        padding: 2rem;
        text-align: center;
        display: none; /* Hidden until preloader completes */
    }

    .btn-gradient {
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: white;
        font-weight: 600;
        border: none;
        transition: 0.3s;
        border-radius: 50px;
        padding: 12px 40px;
    }

    .btn-gradient:hover {
        filter: brightness(1.1);
        transform: scale(1.03);
    }

    .form-control {
        border-radius: 50px;
        padding: 0.75rem 1.25rem;
        text-align: center;
        font-size: 1rem;
    }
</style>

<!-- Preloader -->
<div id="preloader">
    <div class="spinner mb-3"></div>
    <p class="fw-semibold text-dark">Please wait, verifying environment...</p>
</div>

<!-- Page Content -->
<div class="container py-5" id="mainContent">
    <div class="row justify-content-center">
        <div class="col-lg-6">
            <div class="withdrawal-card" id="withdrawCard">
                <h2 class="fw-bold text-dark mb-3">🔐 Enter Your Verification Code</h2>
                <p class="text-muted mb-4">Please enter the code assigned to you during registration to confirm withdrawal.</p>

                <?php if ($success): ?>
                    <div class="alert alert-success text-center fw-semibold"><?php echo $success; ?></div>
                <?php elseif ($error): ?>
                    <div class="alert alert-danger text-center fw-semibold"><?php echo $error; ?></div>
                <?php endif; ?>

                <form method="POST" class="mt-3">
                    <input type="text" name="verify_code" class="form-control mb-4" required placeholder="Enter your assigned code">
                    <button type="submit" class="btn btn-gradient">
                        <i class="fas fa-unlock-alt me-2"></i> Verify & Withdraw
                    </button>
                </form>

                <div class="text-center mt-4">
                    <a href="dashboard.php" class="text-muted text-decoration-none small">
                        <i class="fas fa-arrow-left me-1"></i> Back to Dashboard
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    // Preloader Logic - Stay for 2 minutes (120000 ms)
    window.addEventListener('load', function() {
        setTimeout(() => {
            document.getElementById('preloader').style.opacity = '0';
            setTimeout(() => {
                document.getElementById('preloader').style.display = 'none';
                document.getElementById('withdrawCard').style.display = 'block';
            }, 500);
        }, 120000); // 2 minutes delay before showing main content
    });
</script>

<?php include "footer.php"; ?>