Forums

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

Home Forums Back End How to get quiz results emailed to me and the user?

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #39279
    chicago123
    Member

    Hi,
    I’m just a beginner and I created a quiz on my website using the tutorial at https://css-tricks.com/building-a-simple-quiz/
    I need to get the results when a User does the quiz emailed to me and them (they will provide their email address in a field below the quiz).
    Please provide clear step by step instructions as I am just starting out with this stuff.
    Thanks

    #107595
    chicago123
    Member

    I’m really not getting this. Could someone please get me started on the code for the mail()? I did some but it didn’t work. I need the results of the quiz to be emailed to the user and me, and I also need the quiz to still use grade.php to check the results and allow the user to see their score immediately. Here is the original code:







    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?





      386


















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






      Condo


















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



































    #107632
    chicago123
    Member

    Sorry, I’m really new with this and I’m only in High School. I guess I’ll need to go through this step by step.
    So I’ve created my PHP Quiz. It’s working and the answers are getting checked with the grade.php file, and its displaying a correct score. What’s the next step?

    Thanks for helping

    #107633
    chicago123
    Member

    This is the code for the grade.php page, I don’t know if I’ll need it. BTW I’m using Dreamweaver CS5.5.







    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
    ";
    ?>








    #107748
    chicago123
    Member

    Thanks for the suggestion. I got it to send an email to me by using the code below. Now, I need the same message emailed to the user. I have already created an email address field on the quiz page.

    Thanks!

    
    
    $mailTo = "[email protected]";
    $msgSubject = "Your Trivia Results";
    $msgBody = "Hi!nn";
    $msgBody .= "On Trivia #1 you got ";
    $msgBody .= $totalCorrect . " out of 5 correct!n ";
    $msgBody .= "You earned ";
    $msgBody .= $totalCorrect . "0 SpongeCash!nn";
    $msgBody .= "Here are your Trivia Results:n";
    $msgBody .= $answer1 . "n";
    $msgBody .= $answer2 . "n";
    $msgBody .= $answer3 . "n";
    $msgBody .= $answer4 . "n";
    $msgBody .= $answer5 . "nn";
    $msgBody .= "Remember, you can earn SpongeCash for each Trivia once a week up to five times!nn";
    $msgBody .= "Thanks for Playing!nn";
    $msgBody .= "The Spongebob Fanclub";
    $xHeaders = "From:";

    mail ($mailTo, $msgSubject, $msgBody, $xHeaders);

    ?>
    #107892
    chicago123
    Member

    Please Help!

    #108068
    chicago123
    Member
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.