<?php
require 'db_config.php';

if (isset($_GET['id'])) {
    $user_id = $_GET['id'];

    // Fetch user data from the database
    $stmt = $conn->prepare("SELECT * FROM users WHERE id = ?");
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $user = $result->fetch_assoc();

    if ($user) {
        $fullname = $user['fullname'];
        $qr_code = $user['qr_code'];
    } else {
        echo "User not found.";
        exit();
    }

    $stmt->close();
}

$conn->close();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>QR Code</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }

        button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 20px;
            margin: 10px;
            cursor: pointer;
            font-size: 16px;
            border-radius: 5px;
            transition: background-color 0.3s;
        }

        button:hover {
            background-color: #0056b3;
        }

        h2 {
            font-size: 24px;
            margin: 20px 0;
        }

        img {
            display: block;
            margin: 20px auto;
            width: 200px;
            height: 200px;
        }
    </style>
    
</head>

<body>
    <button onclick="window.location.href='../index.php'">Register</button>
    <button onclick="window.location.href='users.php'">View Participants</button>
    <button onclick="window.location.href='generate_pdf.php?id=<?php echo htmlspecialchars($user_id); ?>'">Generate PDF</button>
    <br><br>
    <h2>QR Code for <?php echo htmlspecialchars($fullname); ?></h2>
    <img src="<?php echo htmlspecialchars($qr_code); ?>" alt="QR Code">
    
    
</body>
</html>
