Developing Webs logo
Web DW-Main DW-Photoshop
Visit the message board for solutions or post a question Check out the Classes offered for free at Developing Webs Voice Chat submit a tutorial, resources, article, font for publication consideration and earn a one way link back to your site Get more specifics about the Developing Webs Voice chat room and its room members View the current news at Developing Webs alternative sites which are resources for your d3evelopment needs Join Developing Webs Chat Link to us on your web page to help support this resource! Check out Developing Webs At yahoo groups! Developing Webs Home Adobe Photoshop Tutorials Macromedia Flash Tutorials Jasc Paint Shop Pro Tutorials Adobe Illustrator Animation basics Some Basic PHP tutorials Perl Tutorials HTML Tutorials Cascading Style Sheets javascript Front Page Tutorials Macromedia Dream Weaver Tutorials dreamweaver Publishing your site, FTP, ChMod, Promotions
RSS Newsfeed
for your site
DW News
DW Forum
Right click on button and copy shortcut

Add to My Yahoo!

Remember to book mark this site!

Request a Tutorial

Creating a PHP Quiz Page

LAB #2

PHP can be used to evaluate Quiz pages. The quiz page may be written in a normal form fashion, either mutiple choice or True-false. After you create this form page, setting your PHP page as the action for the form, your php page can pick up the variables and evaluate the results of the form, scoring the form.


1. Create a 10 question quiz

  • 5 questions should be true false
  • 5 should have 3-5 answer choices.
  • Each question will represent a variable
  • Each variable will be set as a value for the form
  • No entries will cause an error.

2. Create the PHP script that will evaluating the results of the Quiz. The PHP script will return the number of questions right.


Creating the HTML Form

The quiz is written in straight HTML using a form method. write it as the following:

1. Title of your quiz should be written in a heading tag

Mindy's Silly Quiz

2. Instructions for your quiz so the user of the form knows what they are doing.

Select the answer to the question by clicking in the circle in front of the best choice.

3. Start your form with the action set to the PHP filename you will use and the method as "post"
4. Set up your questions as an ordered list to automatically number them.

5. Set your submit button

6. End your form
7. Between your
  • and
  • tags, insert your questions. then paragraph to put in your input statements for your radial buttons.

    Set the value to the answer selection and the name to the question number, such as no1, no spaces, and put your names of what each radial button next to the item.

  • In writing PHP, the form which the variables are set must have be in a document with the extension of .PHP.



  • 8. Do 5 True false questions, then do 5 multiple choice questions. See Form example here

    Creating the PHP result form

    1. Open maguma editor or another PHP editor.
    2. Title your page in HTML.

    Mindy's Silly Beginner PHP Quiz

    3. Put in what this page represents as part of the quiz in HTML.


    4. Set up the PHP opening tag. (already in a php editor) (open script tag)
    (close script tag)
    5. Set the variable $score to 0 so that each time the script is run, the score is reset. $score=0;
    6. Scoring represents testing each line to see if it is true of not. If it is true we will reassign $score so that it is equal to $score + 1. since Question 1 is false, I test to see if $no1 is equal to "false" where "false" is a string.If this is true, 1 is added to the score.

    Number 2 is true, so I test to see if that is the answer they provided. If it is, I add 1 to the score.

    I go through each question like this.

    if ($no1=="false")

    if ($no2=="true")

    7. TO use this as a learning tool, I can put in an if else statement. If they have the right answer I can score a point, else, I give an explanation. Go back and add your explanations as to why their answers were wrong. if ($no1=="false")
    else {
    echo "1. False In writing PHP, the form which the variables are set CAN BE BUT DOES NOT HAVE TO BE in a document with the extension of .PHP.

    8. Add your statement to display your score by using the echo statment. Use the following:
    • HTML included in a quotes to label this score
    • periods to connect the statements.
    echo "

    Your PHP beginner quiz score is ".$score."


    Publish your form and php doc and test it!

    Your PHP beginners quiz.

    "Building The Web Into a Nicer Place -- One Site At A Time"
    Developing Webs Group Copyright © 2001-2018 All Rights Reserved
    Privacy and Legal