Help?

Hey, So i have to do code that prompts the user for his or her grade on three different tests. Grades range from 0 to 100. Ive done this but i keep getting errors. can someone explain how to fix these errors? thanks.

The errors are on lines 11,12,13 or;
[php]
$test1 = $_POST[“Test 1”];
$test2 = $_POST[“Test 2”];
$test3 = $_POST[“Test 3”];
[/php]

[php][/php]

Untitled Document <?php $test1 = $_POST["Test 1"]; $test2 = $_POST["Test 2"]; $test3 = $_POST["Test 3"]; $total = $test1 + $test2 + $test3; $average = ($total / 3); if (!isset($_POST['submit'])) {
	} else {
		echo (!is_numeric($test1)) ? "Please enter a legitimate grade score." : "You entered ".$test1.", "
		.$test2.", and ".$test3.".<br >The total grade point was: ".$total.", and the average grade point was: "
		.round($average).".<br />";
	if (($average >80) && ($average < 100)) {
		echo "<h1>Congratulations! You've got an 'O'!</h1>";
		} elseif (($average>60) && ($average < 79)) {
			echo "<h2>Great, you got an E</h2>";
			} elseif (($average > 40) && ($average < 59)) {
				echo "<h3>You got an A!</h3>";
				} elseif (($average > 30) && ($average < 39)) {
								echo "<h4>You got a P.  This needs to be improved!</h4>";
								} elseif (($average > 10) && ($average < 29)) {
									echo "<h5>You got a D.  This needs to be improved!</h5>";
									} elseif (($average > 0) && ($average < 9)) {
									echo "<h6> style='color:red'>This is bad ".strtoupper("You need to concentrate!!")."</h6>";
									} else {
													echo "You did not follow directions!";
														}	
															}
															?>
[php][/php]

This is my HTML code;

<!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>Untitled Document</title>
</head>

<body>
<!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>Untitled Document</title>
</head>

<body>
<form action= "P02-03.php" method="post">
<br />
<h1>What are your grades?<h1>
Test 1:<input type="text" size="16" maxlength="20" name="Test 1" />
<br />
Test 2:<input type="text" size="16" maxlength="20" name="Test 2" />
<br />
Test 3:<input type="text" size="16" maxlength="20" name="Test 3" />
<br />
<input type="submit" value="Click to Submit"
<br />
<input type="reset" value="Click to Erase and Reset"
</body>
</html>
</body>
</html>

Help? Thanks

PHP will convert the spaces to underscores. You should use ‘Test_1’ for your input name instead.

Sponsor our Newsletter | Privacy Policy | Terms of Service