Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How do I get PHP Quiz Results emailed after being graded? Re: How do I get PHP Quiz Results emailed after being graded?

#107711
chicago123
Member

And here is the code for the grade.php file that is used to grade the quiz (go to ‘https://css-tricks.com/building-a-simple-quiz/” for more info):







PHP Quiz








TRIVIA #1




$answer1 = $_POST;
$answer2 = $_POST;
$answer3 = $_POST;
$answer4 = $_POST;
$answer5 = $_POST;

$totalCorrect = 0;

if ($answer1 == "A") { $totalCorrect++; }
if ($answer2 == "C") { $totalCorrect++; }
if ($answer3 == "B") { $totalCorrect++; }
if ($answer4 == "A") { $totalCorrect++; }
if ($answer5 == "C") { $totalCorrect++; }

echo "
$totalCorrect / 5 correct
";
echo "
You earned $totalCorrect 0 SpongeCash
";
?>
// Set up parameters
$to = "[email protected],'Email Address'";
$subject = "Your Trivia Results";
$message = "Here are your Trivia Results:";
$from = "[email protected]";
$headers = "From: $from";

// Send email
mail($to,$subject,$message,$headers);
?>