Question

This should be in PHP, please For Project 1, you need to create a Web form...

This should be in PHP, please

For Project 1, you need to create a Web form to present a ten (5) Multiple Choice quiz about the Chinese zodiac signs. Indicate that all of the questions must be answered for the quiz to be graded. You can use radio buttons or drop-down boxes Multiple Choice answers.

Requirements for Project 1:

  1. Provide fields for visitors to enter their name and answers to the questions
  2. Notify the visitor that the fields are required fields. Include Submit Quiz and Reset Quiz buttons.
  3. Create a Web form handler to process the entered data when the Submit Quiz button is clicked.
  4. Notify the visitor of the number of questions that are correct and incorrect
  5. Re display the quiz if the form is incomplete; otherwise, evaluate the answers.

Below is the list of questions that should be in the quiz.

1. Which sign is not part of the Chinese zodiac?~Fox~Rat~Pig~Tiger      

2. The Chinese zodiac traditionally begins with which sign?~Monkey~Ox~Rat~Dog            

3. The Chinese zodiac traditionally ends with which sign?~Goat~Pig~Horse~Dog          

4. How many signs are in the Chinese zodiac?~6~8~12~14                   

5. Which is the only reptile that is a sign in the Chinese zodiac?~Snake~Lizard~Turtle~Crocodile                            

6. Chinese zodiac signs represent different types of __?~Ages~Personalities~Nationalities~Moods                       

7. Which is the only bird that is a sign in the Chinese zodiac?~Rooster~Dove~Parrot~Owl                              

8. Which Zodiac animal represent 'Calm, gentle, sympathetic'?~Pig~Horse~Rabbit~Goat                               

9. Which Zodiac animal represent 'Brave, confident, competitive'?~Dog~Horse~Tiger~Snake                         

10. Which is the only bird that is a sign in the Chinese zodiac?~Rooster~Dove~Parrot~Owl                      

Answers:

1.The answer is Fox

2. The answer should be Rat

3. The answer should be Pig

4. The answer is 12

5. The answer is Snake

6. The answer is Personalities

7. The answer is Rooster

8. The answer is Goat

9. The answer is Tiger

10. The answer is Rooster

0 0
Add a comment Improve this question Transcribed image text
Answer #1

We are going to create a web form with the name Quiz. It is a html form for accepting inputs from user. We will process the inputs by using php code. The file containing php code is given as displayResult.php. After user submits the form , the action will be moved to displayResult.php. In that , we will evaluate the answers. Based on that we will provide the score with message. By using the input tag names we are getting the values from web page.

Quiz.html (Web form)

<!DOCTYPE html>

<head>
   <title>Quiz</title>
   <link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
      
   <form action="displayResult.php" method="post" id="quiz">
      
<ol>
  
<li>
  
<h2>1.Which sign is not part of the Chinese zodiac?</h2>
  
<div>
<input type="radio" name="q1-ans" id="q1-ans-A" value="A" required/>
<label for="q1-ans-A">A) Fox</label>
</div>
  
<div>
<input type="radio" name="q1-ans" id="q1-ans-B" value="B" />
<label for="q1-ans-B">B)Rat</label>
</div>
  
<div>
<input type="radio" name="q1-ans" id="q1-ans-C" value="C" />
<label for="q1-ans-C">C) Pig</label>
</div>
  
<div>
<input type="radio" name="q1-ans" id="q1-ans-D" value="D" />
<label for="q1-ans-D">D) Tiger</label>
</div>
  
</li>
  
<li>
  
<h2>2.The Chinese zodiac traditionally begins with which sign?</h2>
  
<div>
<input type="radio" name="q2-ans" id="q2-ans-A" value="A" required/>
<label for="q2-ans-A">A) Monkey</label>
</div>
  
<div>
<input type="radio" name="q2-ans" id="q2-ans-B" value="B" />
<label for="q2-ans-B">B) Ox</label>
</div>
  
<div>
<input type="radio" name="q2-ans" id="q2-ans-C" value="C" />
<label for="q2-ans-C">C) Rat</label>
</div>
  
<div>
<input type="radio" name="q2-ans" id="q2-ans-D" value="D" />
<label for="q2-ans-D">D) Dog</label>
</div>
  
</li>
  
<li>
  
<h2>3.The Chinese zodiac traditionally ends with which sign?</h2>
  
<div>
<input type="radio" name="q3-ans" id="q3-ans-A" value="A" required/>
<label for="q3-ans-A">A) Goat</label>
</div>
  
<div>
<input type="radio" name="q3-ans" id="q3-ans-B" value="B" />
<label for="q3-ans-B">B) Pig</label>
</div>
  
<div>
<input type="radio" name="q3-ans" id="q3-ans-C" value="C" />
<label for="q3-ans-C">C) Horse</label>
</div>
  
<div>
<input type="radio" name="q3-ans" id="q3-ans-D" value="D" />
<label for="q3-ans-D">D) Dog</label>
</div>
  
</li>
  
<li>
  
<h2>4.How many signs are in the Chinese zodiac?</h2>
  
<div>
<input type="radio" name="q4-ans" id="q4-ans-A" value="A" required/>
<label for="q4-ans-A">A) 6</label>
</div>
  
<div>
<input type="radio" name="q4-ans" id="q4-ans-B" value="B" />
<label for="q4-ans-B">B) 8</label>
</div>
  
<div>
<input type="radio" name="q4-ans" id="q4-ans-C" value="C" />
<label for="q4-ans-C">C) 12</label>
</div>
  
<div>
<input type="radio" name="q4-ans" id="q4-ans-D" value="D" />
<label for="q4-ans-D">D) 14</label>
</div>
  
</li>
  
  
<li>
  
<h2>5.Which is the only reptile that is a sign in the Chinese zodiac?</h2>
  
<div>
<input type="radio" name="q5-ans" id="q5-ans-A" value="A" required/>
<label for="q5-ans-A">A) Snake</label>
</div>
  
<div>
<input type="radio" name="q5-ans" id="q5-ans-B" value="B" />
<label for="q5-ans-B">B)Lizard</label>
</div>
  
<div>
<input type="radio" name="q5-ans" id="q5-ans-C" value="C" />
<label for="q5-ans-C">C) Turtle</label>
</div>
  
<div>
<input type="radio" name="q5-ans" id="q5-ans-D" value="D" />
<label for="q5-ans-D">D) Crocodile</label>
</div>
  
</li>
  
<li>   
  
<h2>6.Chinese zodiac signs represent different types of __?</h2>
  
<div>
<input type="radio" name="q6-ans" id="q6-ans-A" value="A" required/>
<label for="q6-ans-A">A) Ages</label>
</div>
  
<div>
<input type="radio" name="q6-ans" id="q6-ans-B" value="B" />
<label for="q6-ans-B">B) Personalities</label>
</div>
  
<div>
<input type="radio" name="q6-ans" id="q6-ans-C" value="C" />
<label for="q6-ans-C">C) Nationalities</label>
</div>
  
<div>
<input type="radio" name="q6-ans" id="q6-ans-D" value="D" />
<label for="q6-ans-D">D) Moods </label>
</div>
  
</li>
  
<li>   
  
<h2>7.Which is the only bird that is a sign in the Chinese zodiac?</h2>
  
<div>
<input type="radio" name="q7-ans" id="q7-ans-A" value="A" required/>
<label for="q7-ans-A">A) Rooster</label>
</div>
  
<div>
<input type="radio" name="q7-ans" id="q7-ans-B" value="B" />
<label for="q7-ans-B">B) Dove</label>
</div>
  
<div>
<input type="radio" name="q7-ans" id="q7-ans-C" value="C" />
<label for="q7-ans-C">C) Parrot</label>
</div>
  
<div>
<input type="radio" name="q7-ans" id="q7-ans-D" value="D" />
<label for="q7-ans-D">D) Owl</label>
</div>
  
</li>
  
<li>
  
<h2>8.Which Zodiac animal represent 'Calm, gentle, sympathetic'?</h2>
  
<div>
<input type="radio" name="q8-ans" id="q8-ans-A" value="A" required/>
<label for="q8-ans-A">A) Pig</label>
</div>
  
<div>
<input type="radio" name="q8-ans" id="q8-ans-B" value="B" />
<label for="q8-ans-B">B) Horse</label>
</div>
  
<div>
<input type="radio" name="q8-ans" id="q8-ans-C" value="C" />
<label for="q8-ans-C">C) Rabbit</label>
</div>
  
<div>
<input type="radio" name="q8-ans" id="q8-ans-D" value="D" />
<label for="q4-ans-D">D) Goat </label>
</div>
  
</li>
  
<li>   

<h2>9.Which Zodiac animal represent 'Brave, confident, competitive'?</h2>
  
<div>
<input type="radio" name="q9-ans" id="q9-ans-A" value="A" required/>
<label for="q9-ans-A">A) Dog</label>
</div>
  
<div>
<input type="radio" name="q9-ans" id="q9-ans-B" value="B" />
<label for="q9-ans-B">B) Horse</label>
</div>
  
<div>
<input type="radio" name="q9-ans" id="q9-ans-C" value="C" />
<label for="q9-ans-C">C) Tiger</label>
</div>
  
<div>
<input type="radio" name="q9-ans" id="q9-ans-D" value="D" />
<label for="q9-ans-D">D) Snake</label>
</div>
  
</li>
  
<li>

<h2>10.Which is the only bird that is a sign in the Chinese zodiac?</h2>
  
<div>
<input type="radio" name="q10-ans" id="q10-ans-A" value="A" required/>
<label for="q10-ans-A">A) Rooster</label>
</div>
  
<div>
<input type="radio" name="q10-ans" id="q10-ans-B" value="B" />
<label for="q10-ans-B">B) Dove</label>
</div>
  
<div>
<input type="radio" name="q10-ans" id="q10-ans-C" value="C" />
<label for="q10-ans-C">C) Parrot</label>
</div>
  
<div>
<input type="radio" name="q10-ans" id="q10-ans-D" value="D" />
<label for="q10-ans-D">D) Owl</label>
</div>
  
</li>
  
</ol>
  
<input type="submit" value="Submit" />
      
       </form>

</body>

</html>

displayResult.php

<html>

<head>
  
   <title>Quiz Result</title>
  
</head>

<body>
      
<?php
<!-- getting values from web form by using input tag names -->
$answer1 = $_POST['q1-ans'];
$answer2 = $_POST['q2-ans'];
$answer3 = $_POST['q3-ans'];
$answer4 = $_POST['q4-ans'];
$answer5 = $_POST['q5-ans'];
$answer6 = $_POST['q6-ans'];
$answer7 = $_POST['q7-ans'];
$answer8 = $_POST['q8-ans'];
$answer9 = $_POST['q9-ans'];
$answer10 =$_POST['q10-ans'];
   <!-- declaring a variable and defining the value -->
$correct_Answers = 0;
    <!-- if the condition met, the correct_Answers variable will be incremented -->
if ($answer1 == "A") { $correct_Answers++; }
if ($answer2 == "C") { $correct_Answers++; }
if ($answer3 == "B") { $correct_Answers++; }
if ($answer4 == "C") { $correct_Answers++; }
if ($answer5 == "A") { $correct_Answers++; }
if ($answer6 == "B") { $correct_Answers++; }
if ($answer7 == "A") { $correct_Answers++; }
if ($answer8 == "D") { $correct_Answers++; }
if ($answer9 == "C") { $correct_Answers++; }
if ($answer10 =="A") { $correct_Answers++; }
    <!-- printing the number of correct answer out of 10 -->
echo "$correct_Answers / 10 are correct";
    <!-- displaying the message "Congrats....." if the all the answers are correct -->
if ($correct_Answers==10)
{
echo "Congrats.....";
}

<!-- displaying the message "Better luck next time... if the above condition is not correct ie. all the answers are not correct. -->
else
{
echo "Better luck next time....";
}
?>
  
</body>

</html>

Add a comment
Know the answer?
Add Answer to:
This should be in PHP, please For Project 1, you need to create a Web form...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • use python IDEL Please highlight the answer Problem 1 Lists. Read the following code and answer...

    use python IDEL Please highlight the answer Problem 1 Lists. Read the following code and answer the next five questions about it. X = ? y=? z = ? zodiac = ["cow", "tiger", "rabbit", "dragon", "snake", "horse" "sheep", "monkey", "dog", "chicken", "pig", "rat"] first_group = zodiac[0:x] second_group = zodiac[x:y] third_group - zodiac[y:z] animals = [] for item in first_group: animals.append(item) for item in third_group: animals.append(item) for item in second group: animals.append(item) #first print statement print (animals) i = ? j...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT