:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/sukhadaworldapp/**
:: Editing File: front_test.php
<?php session_start(); require_once "admin/db.php"; // Count attempts if (!isset($_SESSION['attempts'])) { $_SESSION['attempts'] = 0; } // Fetch 10 random MCQs $sql = "SELECT * FROM mcq_questions WHERE status='active' ORDER BY RAND() LIMIT 10"; $result = mysqli_query($conn, $sql); // Store MCQs in session for checking later $mcqs = []; while ($row = mysqli_fetch_assoc($result)) { // Shuffle options $options = [ 'A' => $row['option_a'], 'B' => $row['option_b'], 'C' => $row['option_c'], 'D' => $row['option_d'] ]; // Random shuffle keys $shuffled = []; $keys = array_keys($options); shuffle($keys); foreach ($keys as $k) { $shuffled[$k] = $options[$k]; } $row['shuffled'] = $shuffled; $mcqs[] = $row; } $_SESSION['quiz'] = $mcqs; ?> <!DOCTYPE html> <html> <head> <title>MCQ Test</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"> </head> <body class="bg-light"> <div class="container my-5"> <div class="card shadow"> <div class="card-header bg-primary text-white"> <h4>MCQ Test (Random 10 Questions)</h4> </div> <div class="card-body"> <form action="front_result.php" method="POST"> <?php foreach ($mcqs as $index => $q): ?> <div class="mb-4 p-3 border rounded bg-white"> <h5>Q<?= $index + 1 ?>. <?= $q['question'] ?></h5> <?php foreach ($q['shuffled'] as $key => $opt): ?> <div class="form-check"> <input class="form-check-input" type="radio" name="answer[<?= $q['id'] ?>]" value="<?= $opt ?>"> <label class="form-check-label"><?= $opt ?></label> </div> <?php endforeach; ?> </div> <?php endforeach; ?> <button class="btn btn-success">Submit Test</button> </form> </div> </div> </div> </body> </html>