Hello. I am attempting to try my luck at PHP. I can not figure out how to call the function in the PHP code. I keep getting a blank page.

I am using a simple html form with an input field and a submit button. When you enter in a particular letter grade, it should return a response based on their answer. Here are the bits of code. Thanks for any assistance.

HTML:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Letter Grades</title>
</head>

<body>
<form action="LetterGrades.php" method="get" >
<p>
Grade: <input type="text" name="grade" />
<input type="submit" />
</p>
</form>
</body>
</html>

PHP:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Letter Grades</title>
</head>

<body>
<?php
function checkGrade($Grade) {
   switch ($Grade) {
      case "A":
         echo "Your grade is excellent.", ($_GET["A"] == "A");
      break;
      
      case "B":
         echo "Your grade is good.", checkGrade("B");
      break;
      
      case "C":
         echo "Your grade is fair.";
         break;
         
      case "D":
         echo "You are barely passing.";
         break;
         
      case "F":
         echo "You failed.";
         break;
      default:
         return "You did not enter a valid letter grade.";
}
}
?>
</body>
</html>

Never mind. I have figured it out. Thanks anyways. I don't see an option to mark as "solved".

There is a link at the bottom of the thread to "Mark as Solved". I've marked this one for you :)

Ah, ok thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.