Give help. Get help.

  • # August 10, 2012 at 8:14 pm

    I created a PHP Quiz using the tutorial at
    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,, 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:

    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    Welcome to the Spongebob Fanclub! | Trivia #1

    TRIVIA #1

    1. In the KRUSTY TOWERS episode, what does Patrick say after Squidward says 'How can you have bags when you just found out this is a hotel?'


    2. In ROCK BOTTOM, what was the name of the Candy Bar Spongebob wanted out of the vending machine?

    3. In ROCK BOTTOM, what is Spongebob's number in line at the Bus Station?


    4. In KARATE ISLAND, what does Udan want Spongebob to buy?


    5. In MRS. PUFF, YOU'RE FIRED, when Spongebob takes apart the boat, what does he build when he puts it back together?

    # August 10, 2012 at 8:14 pm

    And here is the code for the grade.php file that is used to grade the quiz (go to ‘” for more info):

    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    PHP Quiz

    TRIVIA #1

    < ?php

    $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
    < ?php
    // Set up parameters
    $to = ",'Email Address'";
    $subject = "Your Trivia Results";
    $message = "Here are your Trivia Results:";
    $from = "";
    $headers = "From: $from";

    // Send email

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.