- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi,
I created a PHP Quiz using the tutorial at https://css-tricks.com/building-a-simple-quiz/
I need to get the quiz results emailed to me and the user, and graded. It already grades the quiz and displays a score.
I’m really a beginner so I don’t know how to get the results emailed. Someone suggested using the mail() function, with a link to this page, http://php.net/manual/en/function.mail.php, but I don’t know how to use it at all. Could someone please give me detailed instructions – not just a link please.
Help would be greatly appreciated!
Here is the code for my quiz:
Welcome to the Spongebob Fanclub! | Trivia #1
TRIVIA #1
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);
?>