✅ 1. HTML + PHP Form (score_form.php)

 <!DOCTYPE html>

<html>

<head>

  <title> Student Score Grade </title>

</head>

<body>


  <h2>Enter Your Score</h2>


  <form method="post">

    <label for = "score"> Score (0 - 100): </label>

    <input type = "number" name = "score" id = "score" min = "0" max = "100" required>

    <input type = "submit" value = "Check Grade">

  </form>


  <?php

  if ($ _SERVER ["REQUEST_METHOD"] == "POST") {

    $score = $_POST["score"];


    if ($score >= 90) {

      $grade = "A";

    } elseif ($score >= 80) {

      $grade = "B";

    } elseif ($score >= 70) {

      $grade = "C";

    } elseif ($score >= 60) {

      $grade = "D";

    } else {

      $grade = "F";

    }


    echo "<h3> Your Grade is: $ grade </h3>";

  }

  ?>


</body>

</html>

💡 Explanation:

  • Score 90–100= A

  • Score 80–89= B

  • Score 70–79= C

  • Score 60–69= D

  • Score < 60= F


🖥 How to use:

  1. Save this file as score_form.php.

  2. Place it in your htdocsfolder (if using XAMPP).

  3. Open in your browser:
    http://localhost/score_form.php

  4. Enter a score and it will show the grade.


អត្ថបទបន្ទាប់ អត្ថបទមុន