Creating a PHP Quiz involves multiple aspects:
We will use a form to ask the questions:
<!DOCTYPE html>
<html>
<title>PHP Quiz</title>
</head>
<body>
<form action="process.php" method="post">
Simple Quiz
1. What is 2 + 2?
<input type="radio" name="q1" value="2">2
<input type="radio" name="q1" value="3">3
<input type="radio" name="q1" value="4">4
<input type="radio" name="q1" value="5">5
2. What is the capital of France?
<input type="radio" name="q2" value="London">London
<input type="radio" name="q2" value="Berlin">Berlin
<input type="radio" name="q2" value="Paris">Paris
<input type="radio" name="q2" value="Madrid">Madrid
3. What is 3 x 3?
<input type="radio" name="q3" value="6">6
<input type="radio" name="q3" value="9">9
<input type="radio" name="q3" value="12">12
<input type="radio" name="q3" value="15">15
<input type="submit" value="Submit Quiz">
</form>
</body>
Create a file named `process.php` to process the submitted answers.
<?php
$score = 0;
// Process question 1
if (isset($_POST['q1']) && $_POST['q1'] == '4') {
$score++;
}
// Process question 2
if (isset($_POST['q2']) && $_POST['q2'] == 'Paris') {
$score++;
}
// Process question 3
if (isset($_POST['q3']) && $_POST['q3'] == '9') {
$score++;
}
echo "Your score is: " . $score;
?>
h1 {
font-size: 24px;
}
form {
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
}
For now, let's skip this part since the main focus is on PHP.
UPCET Exam
Click Here
SAAT Exam
Click Here
MHT CET Exam
Click Here
IPU CET Exam
Click Here
KCET Exam
Click Here
COMEDK UG Exam
Click Here
VITEEE Exam
Click Here
BITSAT
Click Here
DSAT: Dayanand Sagar Admission Test
Click Here
Career In Animation in india
Click Here
Merchant Navy Courses in india
Click Here
Interior Design Career in india
Click Here
UGC NET Exam
Click Here
B. Ed Exam
Click Here
AFCAT - Air Force Common Admission Test
Click Here
GATE Exam
Click Here
Joint Entrance Examination (JEE)
Click Here
Common Admission Test (CAT)
Click Here
CDS - Combined Defence Services Exam
Click Here