?>
<html>
<head>
</head>
<title>Online test results</title>
<link href="../font.css" rel="stylesheet" type="text/css" />
<body>
<div align="center" class="font">
<?php
$a=0;
$ar=0;
$answers = array(NULL,3, 4, 4, 3, 1, 2, 1, 4, 2, 3, 3, 3, 2, 3); //this is the correct
for ($k=1; $k<=13; $k++) {
answers, the null is because arrays start at 0
if(@$_POST['q'.$k] == $answers[$k]){ //check each answer against its value in the array
$a++;
} else {
//continue
}
$question = $k; //assign the each value in the array to avariable
if(!isset($_POST['q'.$k])){
echo '<br> Question: <b>' . $k . '</b>. You didn\'t answer';
}else{
echo '<br> Question: <b>' . $k . '</b>. You answered ' . @$_POST['q'.$k] . ' which was ' . ((@$_POST['q'.$k] == $answers[$k])?'correct':'incorrect');
}
$ar++;
}
die('<br><br>You answered ' . $a . ' questions correctly!'); //show the answers they got right
?>
<br />
<br />
</div>
</body>
</html>
Edit: You had to go and fix it didn't you.
Actually, your code wouldn't work, it'll only check if the answer is 3 each time.
Edit: oh, just saw it 😉 it doesn.t