PHP passing a value from an HTML form?
I need to add a statement to the end of this script that calls the checkgrade() function and passes to it the value from the grade form variable. Here is my code, I have updated it to show how I think it should be but I am still recieving an error.
<?php
function checkGrade($Grade) {
switch ($Grade) {
case "A":
echo "Your grade is excellent.";
break;
case "B":
echo "Your grade is good.";
break;
case "C":
echo "Your grade is fair.";
break;
case "D":
echo "You are barely passing.";
break;
case "F":
echo "You failed.";
break;
default:
echo "You did not enter a valid letter grade.";
}
$Grade = checkGrade
($Grade = $_GET["Grade"]);
echo "<p>$Grade</p>";
?>
I have an HTML form I am using that has the Get action from this php, with a single text input named Grade. Both validate on W3C. However I am getting an error parsing from the form to the function.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Letter Grades</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</head>
<body>
<form action="LetterGrades.php" method="get">
<p>Grade: <Input type="text" name="Grade" />
<input type="submit" name="submit" value="Submit" /></p>
</form>
</body>
</html>
I KNOW the HTML I already have is correct. My problem is getting the info from the form variable to where it is needed in the.php file. I've used my php validator andI still get zip. Tried the suggestion here and it recieved syntax errors.
Here is what I've got for retrieving the form data in the php now.
If
$Grade = $_GET['Grade'] {
$Grade = checkGrade($Grade);
echo $Grade;
}