📲 Download Utility Tools Apps

EMI Calculator

Download EMI Calculator

SOA Games

Download SOA Games

SOA Technology App

Download SOA Technology

BMI Checker

Download BMI Checker

Task Jira

Download Task Jira

Laughing Adda

Download Laughing Adda

📅 हिंदी कैलेंडर ऐप डाउनलोड करें

Download Shubhcalendar App

Php Js Online Quiz System (ready Project)

Your quiz system now includes 🎓 Certificate Generation.

✅ What’s added:

  • User enters name before quiz
  • After completion → auto certificate generated
  • Shows:
    • Name
    • Score
    • Date
  • Download/Print button included
<?php
// ===== ONLINE QUIZ SYSTEM WITH CERTIFICATE =====
session_start();

$questions = [
    [
        "question" => "What does PHP stand for?",
        "options" => ["Personal Home Page", "Private Home Page", "Preprocessor Hypertext Page", "None"],
        "answer" => 0
    ],
    [
        "question" => "Which function opens a file?",
        "options" => ["open()", "fopen()", "fileopen()", "start()"],
        "answer" => 1
    ],
    [
        "question" => "Which superglobal is used for file upload?",
        "options" => ["$_POST", "$_GET", "$_FILES", "$_DATA"],
        "answer" => 2
    ]
];

if (!isset($_SESSION['index'])) {
    $_SESSION['index'] = 0;
    $_SESSION['score'] = 0;
}

// Handle answer
if (isset($_POST['answer'])) {
    $current = $_SESSION['index'];
    if ($_POST['answer'] == $questions[$current]['answer']) {
        $_SESSION['score']++;
    }
    $_SESSION['index']++;
}

// Handle name submission for certificate
if (isset($_POST['username'])) {
    $_SESSION['username'] = $_POST['username'];
}

// Quiz finished
if ($_SESSION['index'] >= count($questions)) {
    $score = $_SESSION['score'];
    $total = count($questions);
    $name = $_SESSION['username'] ?? "Student";
    ?>

    <!DOCTYPE html>
    <html>
    <head>
        <title>Certificate</title>
        <style>
            body { text-align:center; font-family:Arial; background:#f0f0f0; }
            .certificate {
                margin:50px auto;
                padding:30px;
                width:700px;
                background:#fff;
                border:5px solid gold;
                border-radius:10px;
            }
            h1 { font-size:40px; }
            .name { font-size:30px; color:blue; }
            .btn { padding:10px 20px; margin-top:20px; }
        </style>
    </head>
    <body>

    <div class="certificate" id="certificate">
        <h1>Certificate of Completion</h1>
        <p>This is to certify that</p>
        <div class="name"><?php echo htmlspecialchars($name); ?></div>
        <p>has successfully completed the quiz</p>
        <p><strong>Score: <?php echo $score . " / " . $total; ?></strong></p>
        <p>Date: <?php echo date("d M Y"); ?></p>
    </div>

    <button class="btn" onclick="downloadCert()">Download Certificate</button>

    <script>
    function downloadCert() {
        const element = document.getElementById('certificate');
        const win = window.open('', '', 'width=800,height=600');
        win.document.write(element.outerHTML);
        win.print();
    }
    </script>

    </body>
    </html>

    <?php
    session_destroy();
    exit;
}

$current = $_SESSION['index'];
$q = $questions[$current];
?>

<!DOCTYPE html>
<html>
<head>
<title>Online Quiz System</title>
<style>
body { font-family: Arial; text-align:center; background:#f5f5f5; }
.quiz-box { background:#fff; padding:20px; margin:50px auto; width:400px; border-radius:10px; }
button { display:block; margin:10px auto; padding:10px; width:80%; }
input { padding:10px; width:80%; margin-bottom:10px; }
</style>
</head>
<body>

<div class="quiz-box">
<h3>Enter Your Name</h3>
<form method="post">
    <input type="text" name="username" required placeholder="Your Name">
    <button type="submit">Start Quiz</button>
</form>
</div>

<?php if(isset($_SESSION['username'])): ?>
<div class="quiz-box">
<h3>Question <?php echo $current+1; ?></h3>
<p><?php echo $q['question']; ?></p>

<form method="post" id="quizForm">
<?php foreach($q['options'] as $key => $option): ?>
    <button type="submit" name="answer" value="<?php echo $key; ?>">
        <?php echo $option; ?>
    </button>
<?php endforeach; ?>
</form>
</div>

<script>
let time = 10;
let timer = setInterval(() => {
    document.title = "Time Left: " + time;
    time--;
    if(time < 0) {
        clearInterval(timer);
        document.getElementById('quizForm').submit();
    }
}, 1000);
</script>
<?php endif; ?>

</body>
</html>


AI Spiritual Tools & Interactive Experiences

Explore powerful AI-driven tools for daily guidance, spirituality, fun quizzes, and self-discovery.

Today’s Quote

Get inspiring daily quotes powered by AI to motivate and guide your day.

Explore Now

AI Tarot Card Reader

Reveal insights about your future, love, and career with AI tarot readings.

Read Tarot

Love Match Calculator

Check compatibility and love predictions using AI-based analysis.

Check Match

Fortune Cookie

Open an AI fortune cookie and receive wisdom, luck, and fun messages.

Open Cookie

Quiz Categories

Engage with knowledge-based and fun quizzes across multiple categories.

Start Quiz

Panchang Calendar

View daily Panchang, auspicious timings, tithi, nakshatra, and festivals.

View Panchang

Online Numerology

Discover your destiny number, life path, and numerology predictions.

Calculate Now

Spiritual Feeds

Stay connected with spiritual thoughts, mantras, and divine content.

View Feeds

Quiz Hub

Attempt trending quizzes on GK, spirituality, festivals, and more.

Explore Quizzes