I have a true/false quiz that I would like to show the pass/fail results.
I get zero every time even if I answer all the questions correctly.
[code=php]<?php
$a1 = “true”;
$a2 = “false”;
$a3 = “false”;
$a4 = “true”;
$a5 = “true”;
$a6 = “false”;
$a7 = “false”;
$a8 = “true”;
$a9 = “true”;
$a10 = “false”;
$a11 = “false”;
$a12 = “true”;
$a13 = “true”;
$a14 = “false”;
$name=$_POST[‘name’];
$q1=$_POST[‘q1’];
$q2=$_POST[‘q2’];
$q3=$_POST[‘q3’];
$q4=$_POST[‘q4’];
$q5=$_POST[‘q5’];
$q6=$_POST[‘q6’];
$q7=$_POST[‘q7’];
$q8=$_POST[‘q8’];
$q9=$_POST[‘q9’];
$q10=$_POST[‘q10’];
$q11=$_POST[‘q11’];
$q12=$_POST[‘q12’];
$q13=$_POST[‘q13’];
$q14=$_POST[‘q14’];
$score=0;
if ($q1== $a1) { $score ++; }
if ($q2== $a2) { $score ++; }
if ($q3== $a3) { $score ++; }
if ($q4== $a4) { $score ++; }
if ($q5== $a5) { $score ++; }
if ($q6== $a6) { $score ++; }
if ($q7== $a7) { $score ++; }
if ($q8== $a8) { $score ++; }
if ($q9== $a9) { $score ++; }
if ($q10== $a10) { $score ++; }
if ($q11== $a11) { $score ++; }
if ($q12== $a12) { $score ++; }
if ($q13== $a13) { $score ++; }
if ($q14== $a14) { $score ++; }
if ($score>=10) {
$testresult = ‘Your score is ‘.$score.’ <br />Please click <a href=”certificate.php”>here</a> to print your certificate.’;
} else {
$testresult = ‘Your score is ‘.$score.’ <br /><br />Unfortunately you did not pass the course.<br />Please review your answers and try again.</p>’;
}
?>