:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/sukhadaworldapp/**
:: Editing File: front_result.php
<?php session_start(); require_once "admin/db.php"; // Count attempt $_SESSION['attempts']++; $mcqs = $_SESSION['quiz'] ?? []; $user_answers = $_POST['answer'] ?? []; $score = 0; $total = count($mcqs); $results = []; foreach ($mcqs as $q) { $correct = $q['correct_answer']; $user = $user_answers[$q['id']] ?? 'Not Attempted'; if ($user == $correct) { $score++; } $results[] = [ 'question' => $q['question'], 'correct' => $correct, 'user' => $user ]; } ?> <!DOCTYPE html> <html> <head> <title>Test Result</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-dark text-white"> <h4>Your Result</h4> </div> <div class="card-body"> <h3>Your Score: <span class="text-success"><?= $score ?>/<?= $total ?></span></h3> <h6>Total Attempts: <?= $_SESSION['attempts'] ?></h6> <hr> <h5>Question-wise Result:</h5> <?php foreach ($results as $i => $r): ?> <div class="mb-3 p-3 border rounded bg-white"> <p><strong>Q<?= $i + 1 ?>. <?= $r['question'] ?></strong></p> <p>Your Answer: <strong><?= $r['user'] ?></strong></p> <p>Correct Answer: <strong class="text-success"><?= $r['correct'] ?></strong></p> <?php if ($r['user'] == $r['correct']): ?> <span class="badge bg-success">Correct</span> <?php else: ?> <span class="badge bg-danger">Wrong</span> <?php endif; ?> </div> <?php endforeach; ?> <a href="front_test.php" class="btn btn-primary">Try Again (New Random 10 Questions)</a> </div> </div> </div> </body> </html>