<?php
session_start();

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $_SESSION['student_name'] = $_POST['student_name'];
    $_SESSION['class'] = $_POST['class'];
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Coding Challenges</title>
    <style>
        body { font-family: Arial; background:#f4f6f8; }
        .card {
            background:#fff;
            padding:20px;
            margin:20px auto;
            width:500px;
            border-radius:8px;
        }
        a {
            text-decoration:none;
            color:#0b8c9f;
            font-weight:bold;
        }
    </style>
</head>
<body>

<h2 style="text-align:center;">Coding Challenges</h2>

<?php
$challenges = [
    1 => "Identify the Output",
    2 => "Logical Sequence",
    3 => "Condition Based Thinking",
    4 => "Pattern Recognition",
    5 => "Step-by-Step Logic"
];

foreach ($challenges as $id => $title) {
    echo "
    <div class='card'>
        <h3>$title</h3>
        <a href='attempt.php?id=$id'>Start Challenge</a>
    </div>";
}
?>

</body>
</html>
