Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Grade Calc</title>
- <link href='https://fonts.googleapis.com/css?family=ABeeZee' rel='stylesheet'>
- <style>
- * {
- box-sizing: border-box;
- font-family: ABeeZee;
- text-align: center;
- }
- input[type=number], select, textarea {
- width: 100%;
- padding: 12px;
- border: 1px solid #ccc;
- border-radius: 4px;
- resize: vertical;
- }
- label {
- padding: 12px 12px 12px 0;
- display: inline-block;
- }
- input[type=submit] {
- background-color: #04AA6D;
- color: white;
- padding: 12px 20px;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- float: right;
- }
- input[type=submit]:hover {
- background-color: #45a049;
- }
- .h3 {
- text-align: center;
- font-size: 33px;
- }
- .container {
- border-radius: 5px;
- background-color: #f2f2f2;
- padding: 20px;
- }
- .col-25 {
- float: left;
- width: 25%;
- margin-top: 6px;
- }
- /* Clear floats after the columns */
- .row:after {
- content: "";
- display: table;
- clear: both;
- }
- /* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
- @media screen and (max-width: 600px) {
- .col-25, input[type=submit] {
- width: 100%;
- margin-top: 0;
- }
- }
- </style>
- </head>
- <body>
- <?php
- // Define Variables
- $bangla_1st = $bangla_2nd = $english_1st = $english_2nd = $general_math = $higher_math = $biology = $physics = $chemistry = $social_science = $religious = "";
- // Request Method
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $bangla_1st = getResult($_POST["bangla_1st"]);
- $bangla_2nd = getResult($_POST["bangla_2nd"]);
- $english_1st = getResult($_POST["english_1st"]);
- $english_2nd = getResult($_POST["english_2nd"]);
- $general_math = getResult($_POST["general_math"]);
- $higher_math = getResult($_POST["higher_math"]);
- $biology = getResult($_POST["biology"]);
- $physics = getResult($_POST["physics"]);
- $chemistry = getResult($_POST["chemistry"]);
- $social_science = getResult($_POST["social_science"]);
- $religious = getResult($_POST["religious"]);
- }
- // Get Data/Results
- function getResult($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- // Grade Calculation
- function gradeCacl() {
- if (0 >= 80 && 0 <= 100) {
- echo "A+";
- } elseif (0 >= 70 && 0 <= 79) {
- echo "A";
- } elseif (0 >= 60 && 0 <= 69) {
- echo "A-";
- } elseif (0 >= 50 && 0 <= 59) {
- echo "B";
- } elseif (0 >= 40 && 0 <= 49) {
- echo "C";
- } elseif (0 >= 33 && 0 <= 39) {
- echo "D";
- } elseif (0 >= 00 && 0 <= 32) {
- echo "F";
- }
- }
- ?>
- <div class="h3">Grade Calc</div>
- <div class="container">
- <form name="grade_calc" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- <div class="row">
- <div class="col-25">
- <label>Bangla First Paper</label>
- <label>
- <input type="number" name="bangla_1st" required />
- </label>
- </div>
- <div class="col-25">
- <label>Bangla Second Paper</label>
- <label>
- <input type="number" name="bangla_2nd" required />
- </label>
- </div>
- <div class="col-25">
- <label>English First Paper</label>
- <label>
- <input type="number" name="english_1st" required />
- </label>
- </div>
- <div class="col-25">
- <label>English Second Paper</label>
- <label>
- <input type="number" name="english_2nd" required />
- </label>
- </div>
- <div class="col-25">
- <label>General Mathematics</label>
- <label>
- <input type="number" name="general_math" required />
- </label>
- </div>
- <div class="col-25">
- <label>Higher Mathematics</label>
- <label>
- <input type="number" name="higher_math" required />
- </label>
- </div>
- <div class="col-25">
- <label>Biology (G/Science)</label>
- <label>
- <input type="number" name="biology" required />
- </label>
- </div>
- <div class="col-25">
- <label>Physics (G/Science)</label>
- <label>
- <input type="number" name="physics" required />
- </label>
- </div>
- <div class="col-25">
- <label>Chemistry (Science)</label>
- <label>
- <input type="number" name="chemistry" required />
- </label>
- </div>
- <div class="col-25">
- <label>Social Science (H. C)</label>
- <label>
- <input type="number" name="social_science" required />
- </label>
- </div>
- <div class="col-25">
- <label>Islam/Hind (Religious)</label>
- <label>
- <input type="number" name="religious" required />
- </label>
- </div>
- </div>
- <div class="row">
- <input type="submit" value="Calculate Me!">
- </div>
- </form>
- </div>
- <?php
- if ($bangla_1st || $bangla_2nd || $english_1st || $english_2nd || $general_math || $higher_math || $biology || $physics || $chemistry || $social_science || $religious) {
- echo "<p>Form Validation Results</p>";
- if ($bangla_1st) {
- echo "Bangla 1st Paper: " . $bangla_1st . "<br />";
- }
- if ($bangla_2nd) {
- echo "Bangla 2nd Paper: " . $bangla_2nd . "<br />";
- }
- if ($english_1st) {
- echo "English 1st Paper: " . $english_1st . "<br />";
- }
- if ($english_2nd) {
- echo "English 2nd Paper: " . $english_2nd . "<br />";
- }
- if ($general_math) {
- echo "General Math: " . $general_math . "<br />";
- }
- if ($higher_math) {
- echo "Higher Math: " . $higher_math . "<br />";
- }
- if ($biology) {
- echo "Biology: " . $biology . "<br />";
- }
- if ($physics) {
- echo "Physics: " . $physics . "<br />";
- }
- if ($chemistry) {
- echo "Chemistry: " . $chemistry . "<br />";
- }
- if ($social_science) {
- echo "Social Science: " . $social_science . "<br />";
- }
- if ($religious) {
- echo "Religious: " . $religious . "<br />";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement