hello i m just a beginner it has been about a week i have starting my journey with php and i m trying to make a simple php quiz script and i have coded the following script but it doesn't gives the output as i expected can some pls guide me or check wt is wrong here
<?php
$question1 = "<b>Question 1: What does PHP stands for? </b><br />
<input type='checkbox' name='q1a' value='a'>Personal Home Page<br />
<input type='checkbox' name='q1a' value='b'>PHP Hypertext PreProcessor<br />
<input type='checkbox' name='q1a' value='c'>Private House Page<br />
<input type='checkbox' name='q1a' value='d'>None of the above<br />
<input type='submit' value='next'>";
$question1_answer = "b";
$question2 = "<b>Question 2: Which one is the PHP ending tag?</b><br />
<input type='checkbox' name='q2a' value='a'>?><br />
<input type='checkbox' name='q2a' value='b'></php></br>
<input type='checkbox' name='q2a' value='c'> We don't end php<br />
<input type='checkbox' name='q2a' value='d'> None<br />
<input type='submit' value='next'>";
$question2_answer = "b";
$question3 = "<b>Question 3: How can you write \"Hello World\" in php?>/b><br />
<input type='radio' name='q3a' value='a'>write(\"hello world\")<br />
<input type='radio' name='q3a' value='b'>document.echo('hello world')<br />
<input type='radio' name='q3a' value='c'>echo(\"Hello World\");<br />
<input type='radio' name='q3a' value='d'>I don't know<br />
<input type='submit' value='next'>";
$question3_answer = "c";
$error = "you should select at least one answer";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
<?php echo "Question no." .$_GET[question]; ?>
</title>
</head>
<body>
<?php
switch ($_GET[question]) {
case "1":
if ($question1_answer== $_POST[q1a]) {
echo "<form method='POST' action='quiz.php?question=2'>
$question1
</form>";
} else {
echo $error. "<form method='POST' action='quiz.php?question=1'>
$question1
</form>";
}
break;
case "2":
if ($question2_answer==$_POST[q1a]) {
$_GET[score]++;
echo "<form method='POST' action='quiz.php?question=3'>
$question2
</form>";
} else {
echo $error. "<form method='POST' action='quiz.php?question=2'>
$question2
</from>";
}
break;
case "3":
if ($question3_answer==$_POST[q1a]) {
$_GET[score]++;
echo "<form method='POST' action='quiz.php?score'>
$question3
</form>";
} else {
echo $error. "<form method='POST' action='quiz.php?question=3'>
$question3
</form>";
}
break;
default:
echo "welcome to simple php quiz <br />
<a href='quiz.php?question=1'>click here to start</a>";
}
?>
</body>
</html>
regards,
jesi.