baru - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of baru.php

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Syarif Hidayat</title>
  5.     <link rel="stylesheet" type="text/css" href="css/sk4.css">
  6. </head>
  7. <body>
  8.     <form method="POST" action="akhir.php">
  9.         <table align="center">
  10.             <tr>
  11.                 <td>Nilai Tugas</td>
  12.                 <td><input type="text" name="tugas"></td>
  13.             </tr>
  14.             <tr>
  15.                 <td>Nilai Ulangan Harian</td>
  16.                 <td><input type="text" name="harian"></td>
  17.             </tr>
  18.             <tr>
  19.                 <td>Nilai UTS</td>
  20.                 <td><input type="text" name="ulangan"></td>
  21.             </tr>
  22.             <tr>
  23.                 <td>Nilai UAS</td>
  24.                 <td><input type="text" name="akhiran"></td>
  25.             </tr>
  26.             <tr>
  27.                 <td></td>
  28.                 <td><input  class="button" type="submit" name="submit"></td>
  29.             </tr>
  30.         </table>
  31.     </form>
  32.     
  33.     <?php 
  34.  $tugas =(float) $_POST['tugas']*20/100;
  35.  $harian = (float)$_POST['harian']*10/100;
  36.  $uts = (float)$_POST['ulangan']*30/100;
  37.  $uass = $_POST['akhiran']*40/100;
  38.  
  39.  $jumlah = $tugas + $harian + $uts + $uass;
  40.  // echo $jumlah;
  41.  ?>
  42. <!DOCTYPE html>
  43. <html>
  44. <head>
  45.  <title>Akhir</title>
  46. </head>
  47. <body>
  48.  <?php 
  49.   if ($jumlah > 80) {
  50.    echo "<p style='color : green'>
  51. A : $jumlah</p>
  52. ";
  53.   }else if($jumlah >= 70 || $jumlah <= 79){
  54.    echo "<p style='color : blue'>
  55. B : $jumlah</p>
  56. ";
  57.   }else if ($jumlah >= 60 || $jumlah <= 69) {
  58.    echo "<p style='color : yellow'>
  59. C : $jumlah";
  60.   }else if ($jumlah >= 50 || $jumlah <= 59) {
  61.    echo "<p style='color : orange'>
  62. D : $jumlah</p>
  63. ";
  64.   }else if ($jumlah < 50) {
  65.    echo "<p style='color : red'>E : $jumlah</p>
  66. ";
  67.   }else{
  68.    echo "suram";
  69.   }
  70.   ?>
  71. </body>
  72. </html>
  73. </body>
  74. </html>
  75.  
File Description
  • baru
  • PHP Code
  • 22 Oct-2019
  • 1.78 Kb
You can Share it: