Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs
Code: Select all
This is the code I am using. I have all the answers set to 1 at the moment as I'm trying to get it to work. Any help would be greatly appreciated.
Many Thanks
<html>
<body>
<?php
//Checks that all questions have been answered and name entered.
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['q16'] == ''||$_POST['q17'] == ''||$_POST['q18'] == ''||
$_POST['q19'] == ''||$_POST['q20'] == '')
{
echo '<center><img src = assessment_header.jpg></center><br><br>';
echo "Please go back and enter your name, review and answer all questions.\n";
}
//Checks for correct answers and increases $score if correct.
else
{
$score = 0;
if($_POST['q1'] == 1)
$score++;
if($_POST['q2'] == 1)
$score++;
if($_POST['q3'] == 1)
$score++;
if($_POST['q4'] == 1)
$score++;
if($_POST['q5'] == 1)
$score++;
if($_POST['q6'] == 1)
$score++;
if($_POST['q7'] == 1)
$score++;
if($_POST['q8'] == 1)
$score++;
if($_POST['q9'] == 1)
$score++;
if($_POST['q10'] == 1)
$score++;
if($_POST['q11'] == 1)
$score++;
if($_POST['q12'] == 1)
$score++;
if($_POST['q13'] == 1)
$score++;
if($_POST['q14'] == 1)
$score++;
if($_POST['q15'] == 1)
$score++;
if($_POST['q16'] == 1)
$score++;
if($_POST['q17'] == 1)
$score++;
if($_POST['q18'] == 1)
$score++;
if($_POST['q19'] == 1)
$score++;
if($_POST['q20'] == 1)
$score++;
$score1 = $score /20 * 100; //makes score a precent.
}
if($score1 > 99 )//A score of over 99%
{
$passNumber = file_get_contents("registration");
$passNumber = (int)$passNumber;
$passNumber++;
file_put_contents("registration", $passNumber);
echo '<center><img src = assessment_header.jpg></center><br><br>';
echo "\n";
echo '<center><A HREF = "certsubmit.html"> Congratulations You Have Passed. Click here to complete your certificate </center><br></A>';
echo "\n";
echo "<center>You will be provided with a safety booklet. Please read it, sign and return Declaration page to Head Office or Supervisor before starting work.</center>";
// sends email with name and list of answers.
$to = "info@construction.com";
$subject = " Induction";
$message = "Results for " . $_POST['fname'] . " (#" . $passNumber . "):\n";
$message .= "\n";
$headers = "From: webmaster@bwebsites.com";
for ($i = 1; $i <= 20; $i++)
{
if (isset($_POST['q' . $i]))
$message .= "Answer for question " . $i . ": " . $_POST['q' . $i] . "\n";
}
mail($to, $subject, $message, $headers);
else
{
echo '<center><img src = assessment_header.jpg></center><br><br>';
echo '<center><br><A HREF = "test.html"> Please click here and attempt the Assessment again.</A></center>';
}
?>
</body>
</html>