Jump to content

PHP Help!


Paigem805

Recommended Posts

I am having trouble finding where my error is... I created a quiz and the page below is the page that yields the results of the graded quiz.  I have been starring at it for several hours and just cannot find where I have stumbled up... anyone with fresh eyes that would like to give a look, I would really appreciate it. 

 

Thanks ;)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Quiz Results</title>

<link href="style.css" rel="stylesheet" type="screen" />

</head>

 

 

<body>

<?php

include('includes/banner.inc.php');

include('includes/header.inc.php');

include('includes/menu.inc.php');

include('includes/banner2.inc.php');

?>

<br/>

 

 

<div id="container">

 

<h1>Let's see how you did!</h1>

<br/>

<br/>

<?php

 

 

 

$thescore = 100;

 

/* The Key */

$A1 = "B";

$A2 = "D";

$A3 = "B";

$A4 = "D";

$A5 = "B";

$A6 = "C";

$A7 = "C";

$A8 = "C";

$A9 = "B";

$A10 = "B";

$A11 = "A";

$A12 = "C";

$A13 = "B";

$A14 = "C";

$A15 = "B";

 

if ($_POST['Q1'] == "") {Q1 = "X";} else {$Q1 = $_POST['Q1'];}

if ($_POST['Q2'] == "") {Q2 = "X";} else {$Q2 = $_POST['Q2'];}

if ($_POST['Q3'] == "") {Q3 = "X";} else {$Q3 = $_POST['Q3'];}

if ($_POST['Q4'] == "") {Q4 = "X";} else {$Q4 = $_POST['Q4'];}

if ($_POST['Q5'] == "") {Q5 = "X";} else {$Q5 = $_POST['Q5'];}

if ($_POST['Q6'] == "") {Q6 = "X";} else {$Q6 = $_POST['Q6'];}

if ($_POST['Q7'] == "") {Q7 = "X";} else {$Q7 = $_POST['Q7'];}

if ($_POST['Q8'] == "") {Q8 = "X";} else {$Q8 = $_POST['Q8'];}

if ($_POST['Q9'] == "") {Q9 = "X";} else {$Q9 = $_POST['Q9'];}

if ($_POST['Q10'] == "") {Q10 = "X";} else {$Q10 = $_POST['Q10'];}

if ($_POST['Q11'] == "") {Q11 = "X";} else {$Q11 = $_POST['Q11'];}

if ($_POST['Q12'] == "") {Q12 = "X";} else {$Q12 = $_POST['Q12'];}

if ($_POST['Q13'] == "") {Q13 = "X";} else {$Q13 = $_POST['Q13'];}

if ($_POST['Q14'] == "") {Q14 = "X";} else {$Q14 = $_POST['Q14'];}

if ($_POST['Q15'] == "") {Q51 = "X";} else {$Q15 = $_POST['Q15'];}

 

 

echo "<p class = \"thequestion\"> Question 1: An important first step in designing a Web site is to: </p>";

if (Q1 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q1 == $A1) {

echo "<p> That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q1']  Sorry that is incorrect.  The correct answer is $A1.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 2:  Usability testing for a Web site can be performed with: </p>";

if (Q2 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q2 == $A2) {

echo "<p> That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q2'].  Sorry that is incorrect.  The correct answer is $A2.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class = \"thequestion\" > Question 3:  Multimedia should be used: </p>";

if (Q3 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q3 == $A3) {

echo "<p> That's Correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q3'].  Sorry that is incorrect.  The correct answer is $A3.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class = \"thequestion\" > Question 4:  To organize information on a Web page, grouping can be used to differentiate related and unrelated information by: </p>";

if (Q4 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q4 == $A1) {

echo "<p> That's Corret!</p>";

} else {

echo "<p> Your answer was $_POST['Q4'].  Sorry that is incorrect.  The correct answer is $A4.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class = \"thequestion\"> Question 5: Items on a Web page can be sequenced based on each of the following except: </p>";

if (Q5 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q5 == $A5) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q5'].  Sorry that is incorrect.  The correct answer is $A5.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> In general, when writing for the Web, one should do all of the following except: </p>";

if (Q6 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q6 == $A6) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q6'].  Sorry that is incorrect.  The correct answer is $A6.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 7:  Guidelines for good color usage include all of these points except: </p>";

if (Q7 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q7 == $A7) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q7'].  Sorry that is incorrect.  The correct answer is $A7.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 8: Red text should not be used on a blue background because: </p>";

if (Q8 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q8 == $A8) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q8'].  Sorry that is incorrect.  The correct answer is $A8.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 9:  In the list below, which item is NOT expected to be revealed by a storyboard? </p>";

if (Q9 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q9 == $A9) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q9'].  Sorry that is incorrect.  The correct answer is $A9.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 10:  Which of the following is one goal of using link titles? </p>";

if (Q10 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q10 == $A10) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q01'].  Sorry that is incorrect.  The correct answer is $A10.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 11:  In order to determine the target audience for your site, what is a question that you should ask yourself?</p>";

if (Q11 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q11 == $A11) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q11'].  Sorry that is incorrect.  The correct answer is $A11.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 12:  Which of the following items are NOT essential for an error page? </p>";

if (Q12 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q12 == $A12) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q12'].  Sorry that is incorrect.  The correct answer is $A12.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 13:  Which of the following items is NOT a way to specify a color? </p>";

if (Q13 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q13 == $A13) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q13'].  Sorry that is incorrect.  The correct answer is $A13.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 14:  You are creating an animated image for your site. What image format will you use? </p>";

if (Q14 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q14 == $A14) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q14'].  Sorry that is incorrect.  The correct answer is $A14.</p>";

$thescore = $thescore - 3;

}

 

echo "<p class =\"thequestion\"> Question 15:  Why would you want to create a site mock-up? </p>";

if (Q15 == "X") {

echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q15 == $A15) {

echo "<p>That's correct!</p>";

} else {

echo "<p> Your answer was $_POST['Q15'].  Sorry that is incorrect.  The correct answer is $A15.</p>";

$thescore = $thescore - 3;

}

 

 

?>

 

<br/>

<br/>

<br/>

<div id="showscore">

<h2>Your Score</h2>

<?php

echo "$thescore%";

?>

</div>

<?php

include('includes/footer.inc.php');

?>

</div>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/218044-php-help/
Share on other sites

You're missing a $ from each section:-

 

echo "<p class = \"thequestion\"> Question 1: An important first step in designing a Web site is to: </p>";

  if (Q1 == "X") {

      echo "<p> You skipped this question.</p>";

$thescore = $thescore - 3;

} elseif ($Q1 == $A1) {

      echo "<p> That's correct!</p>";

} else {

      echo "<p> Your answer was $_POST['Q1']  Sorry that is incorrect.  The correct answer is $A1.</p>";

$thescore = $thescore - 3;

}

 

Link to comment
https://forums.phpfreaks.com/topic/218044-php-help/#findComment-1131508
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.