I'm trying to get the page after clicking submit to tell the user if they got the question correct or not. As of right now, it always says its correct, regardless if what's typed into the text box is the correct answer or not. Any help would be greatly appreciated thanks.
Here is the code in question. The first part is from the html file creating the questions.
<form action="Graded.php" method="post" id="quiz">
Question 7: How many signs are in the Chinese zodiac?
<input type="text" name="question-7-answers" value="" required>
Question 8: Which is the only reptile that is a sign in the Chinese zodiac?
<input type="text" name="question-8-answers" value="" required>
Question 9: Which is the only imaginary animal that is a sign in the Chinese zodiac?
<input type="text" name="question-9-answers" value="" required>
Question 10: Which is the only bird that is a sign in the Chinese zodiac?
<input type="text" name="question-10-answers" value="" required>
<input type="submit" value="Submit Quiz"/>
<input type="reset" value="Reset Quiz" class="reset_button"/>
</form>
Here is the php part that checks to see if the answer is correct and posts the result on the page after clicking submit.
$answer7 = $_POST['question-7-answers'];
$answer8 = $_POST['question-8-answers'];
$answer9 = $_POST['question-9-answers'];
$answer10 = $_POST['question-10-answers'];
if ($answer7 == "12" || "twelve") { $totalCorrect++; echo "Answer 7 was Correct <br />\n";}
else echo"Incorrect answer. This is the correct answer: Question 7: How many signs are in the Chinese zodiac? Answer: 12 <br />\n";
if ($answer8 == "Snake" || "snake") { $totalCorrect++; echo "Answer 8 was Correct <br />\n";}
else echo "Incorrect answer. This is the correct answer: Question 8: Which is the only reptile that is a sign in the Chinese zodiac? Answer: Snake <br />\n";
if ($answer9 == "Dragon" || "dragon") { $totalCorrect++; echo "Answer 9 was Correct <br />\n";}
else echo "Incorrect answer. This is the correct answer: Question 9: Which is the only imaginary animal that is a sign in the Chinese zodiac? Answer: Dragon <br />\n";
if ($answer10 == "Rooster" || "rooster") { $totalCorrect++; echo "Answer 10 was Correct <br />\n";}
else echo "Incorrect answer. This is the correct answer: Question 10: Which is the only bird that is a sign in the Chinese zodiac? Answer: Rooster <br />\n";
Here is the updated code with the fixed if statements
if ($answer7 == "12" || $answer7 == "twelve") { $totalCorrect++; echo "Answer 7 was Correct <br />\n";}
else echo"Incorrect answer. This is the correct answer: Question 7: How many signs are in the Chinese zodiac? Answer: 12 <br />\n";
if ($answer8 == "Snake" || $answer8 == "snake") { $totalCorrect++; echo "Answer 8 was Correct <br />\n";}
else echo "Incorrect answer. This is the correct answer: Question 8: Which is the only reptile that is a sign in the Chinese zodiac? Answer: Snake <br />\n";
if ($answer9 == "Dragon" || $answer9 == "dragon") { $totalCorrect++; echo "Answer 9 was Correct <br />\n";}
else echo "Incorrect answer. This is the correct answer: Question 9: Which is the only imaginary animal that is a sign in the Chinese zodiac? Answer: Dragon <br />\n";
if ($answer10 == "Rooster" || $answer10 == "rooster") { $totalCorrect++; echo "Answer 10 was Correct <br />\n";}
else echo "Incorrect answer. This is the correct answer: Question 10: Which is the only bird that is a sign in the Chinese zodiac? Answer: Rooster <br />\n";