Hi, can anyone give me a bit of advise? Ok this code works and sends a result if it is higher than 99% to an email address. What I now need to do is limit the number of times a person can access the quiz if they don't score 99% in say, three attempts. I think I probably need to use session control some how or a for loop in the final else statement. Any assistance would be appreciated.
<html>
<body>
<?php
if($_POST['q1']== ''||$_POST['q2']== ''||$_POST['q3']== ''||$_POST['q4']== ''||$_POST['q5']== ''||$_POST['q6']== ''||$_POST['q7']== ''||$_POST['q8']== ''||$_POST['q9']== ''||$_POST['q10'] == ''||$_POST['q11'] == ''||$_POST['q12'] == ''||$_POST['q13'] == ''||$_POST['q14'] == ''||$_POST['q15'] == ''||$_POST['16'] == ''||$_POST['q17'] == ''||$_POST['q18'] == ''||$_POST['q19'] == ''||$_POST['q20'] == ''||$_POST['q21']== ''||$_POST['q22'] == ''||$_POST['q23'] == ''||$_POST['q24'] == ''||$_POST['q25'] == ''||$_POST['q26'] == ''||$_POST['q27'] == ''||$_POST['q28'] == ''||$_POST['fname'] == '')
{
echo "Please go back and enter your name and answer all questions";
}
else
{
$score = 0;
if($_POST['q1'] == 4)
$score++;
if($_POST['q2'] == 3)
$score++;
if($_POST['q3'] == 5)
$score++;
if($_POST['q4'] == 1)
$score++;
if($_POST['q5'] == 1)
$score++;
if($_POST['q6'] == 1)
$score++;
if($_POST['q7'] == 2)
$score++;
if($_POST['q8'] == 1)
$score++;
if($_POST['q9'] == 1)
$score++;
if($_POST['q10'] == 2)
$score++;
if($_POST['q11'] == 5 )
$score++;
if($_POST['q12'] == 4)
$score++;
if($_POST['q13'] == 4)
$score++;
if($_POST['q14'] == 3)
$score++;
if($_POST['q15'] == 3)
$score++;
if($_POST['q16'] == 4)
$score++;
if($_POST['q17'] == 2)
$score++;
if($_POST['q18'] == 2)
$score++;
if($_POST['q19'] == 4)
$score++;
if($_POST['q20'] == 2)
$score++;
if($_POST['q21'] == 1)
$score++;
if($_POST['q22'] == 1)
$score++;
if($_POST['q23'] == 4)
$score++;
if($_POST['q24'] == 1)
$score++;
if($_POST['q25'] == 1)
$score++;
if($_POST['q26'] == 1)
$score++;
if($_POST['q27'] == 2)
$score++;
if($_POST['q28'] == 4)
$score++;
$score1 = $score /27 *100;
}
if($score1 > 99)
echo '<A HREF = "certsubmit.html"> Congratulations You Have Passed.';
else
echo "Please click the Browser Back Button and attempt the Assessment again";
$to = "info@*******.com";
$subject = "Entry Quiz";
$message = "Results for " . $_POST['fname'] . ":\n";
$message .= "\n";
for ($i = 1; $i <= 28; $i++)
{
if (isset($_POST['q' . $i]))
$message .= "Answer for question " . $i . ": " . $_POST['q' . $i] . "\n";
}
$headers = "From: [email]webmaster@*******.com[/email]";
mail($to, $subject, $message, $headers);
?>
</body>
</html>