File manager - Edit - /home/kridsana/webapp.cm.in.th/663012801/u66301280013/p002/p002/index.php
Back
<!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>ฟอร์มกรอกคะแนนและคำนวณเกรด</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 20px; background-color: #CAA3DB; } .form-container { background-color: #5B66DB; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); max-width: 600px; margin: auto; } h2 { text-align: center; } table { width: 100%; margin-bottom: 20px; } table td { padding: 10px; text-align: left; } table input { width: 60%; padding: 8px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; } .form-group { text-align: center; } .form-group input[type="submit"] { background-color: #4CAF50; color: white; border: none; cursor: pointer; font-size: 18px; } .form-group input[type="submit"]:hover { background-color: #45a049; } .result { margin-top: 20px; padding: 15px; background-color: #eef2f3; border: 1px solid #ccc; border-radius: 8px; text-align: center; font-size: 18px; } .result h3 { margin: 0; } .result p { margin: 10px 0; } </style> </head> <body> <div class="form-container"> <h2>ฟอร์มกรอกคะแนนและคำนวณเกรด</h2> <form id="gradeForm" method="post" action=""> <table> <tr> <td><label for="spirit">จิตพิสัย (20 คะแนน)</label></td> <td><input type="number" id="spirit" name="spirit" min="0" max="20" required>คะแนน</td> </tr> <tr> <td><label for="test">แบบทดสอบ (30 คะแนน)</label></td> <td><input type="number" id="test" name="test" min="0" max="30" required>คะแนน</td> </tr> <tr> <td><label for="assignment">งาน (20 คะแนน)</label></td> <td><input type="number" id="assignment" name="assignment" min="0" max="20" required>คะแนน</td> </tr> <tr> <td><label for="final_exam">สอบปลายภาค (30 คะแนน)</label></td> <td><input type="number" id="final_exam" name="final_exam" min="0" max="30" required>คะแนน</td> </tr> </table> <div class="form-group"> <input type="submit" value="คำนวณเกรด"> </div> </form> <!-- แสดงผลคะแนนรวมและเกรด --> <?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?> <?php // รับค่าคะแนนจากฟอร์ม $spirit = isset($_POST['spirit']) ? intval($_POST['spirit']) : 0; $test = isset($_POST['test']) ? intval($_POST['test']) : 0; $assignment = isset($_POST['assignment']) ? intval($_POST['assignment']) : 0; $finalExam = isset($_POST['final_exam']) ? intval($_POST['final_exam']) : 0; // คำนวณคะแนนรวม $totalScore = $spirit + $test + $assignment + $finalExam; // กำหนดเกรดตามคะแนนรวม $grade = ''; if ($totalScore >= 80) { $grade = 'A'; } elseif ($totalScore >= 75) { $grade = 'B+'; } elseif ($totalScore >= 70) { $grade = 'B'; } elseif ($totalScore >= 65) { $grade = 'C+'; } elseif ($totalScore >= 60) { $grade = 'C'; } elseif ($totalScore >= 55) { $grade = 'D+'; } elseif ($totalScore >= 50) { $grade = 'D'; } else { $grade = 'F'; } ?> <div id="result" class="result"> <p>คะแนนรวม: <?php echo $totalScore; ?> คะแนน</p> <p>เกรดที่ได้รับ: <?php echo $grade; ?></p> </div> <?php endif; ?> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.39 |
proxy
|
phpinfo
|
Settings