fork download
  1. !DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Latihan</title>
  5. </head>
  6.  
  7. <body>
  8. <form method = 'post' action = '<?php echo $_SERVER['PHP_SELF']; ?>'>
  9. <table style="width: 300px">
  10. <tr>
  11. <td><strong>PANJANG</strong></td>
  12. <td><strong>LEBAR</strong></td>
  13. </tr>
  14. <tr>
  15. <td><input type="text" name="panjang" placeholder="PANJANG" /></td>
  16. <td><input type="text" name="lebar" placeholder="LEBAR" /></td>
  17. </tr>
  18. <tr>
  19. <td><br />
  20. <!--Button HITUNG-->
  21. <label>
  22. <input type="submit" name="submit" value="HITUNG">
  23. </label>
  24. </td>
  25. </tr>
  26. </table>
  27. </form>
  28.  
  29. <div id="hasil">
  30. <?php
  31. error_reporting (E_ALL ^ E_NOTICE);
  32. ?>
  33.  
  34. <?php
  35. /*Proses Penghitungan*/
  36. $panjang = $_POST['panjang'];
  37. $lebar = $_POST['lebar'];
  38.  
  39. $luas = $panjang * $lebar;
  40. $keliling = (2 * $panjang) + (2 * $lebar);
  41.  
  42. /*Proses Cetak*/
  43. echo ("<BR>");
  44. echo "Panjang = $panjang";
  45. echo ("<BR>");
  46. echo "Lebar = $lebar";
  47. echo ("<BR>");
  48. echo "Luas Bangun = $luas";
  49. echo ("<BR>");
  50. echo "Keliling Bangun = $keliling";
  51. ?>
  52. </div>
  53. </body>
  54. </html>
Success #stdin #stdout 0.02s 24696KB
stdin
Standard input is empty
stdout
!DOCTYPE html>
<html>
   <head>
      <title>Latihan</title>
   </head>
      
      <body>
         <form method = 'post' action = 'prog.php'>
	    <table style="width: 300px">
	       <tr>
	          <td><strong>PANJANG</strong></td>
		  <td><strong>LEBAR</strong></td>
	       </tr>
	       <tr>
		   <td><input type="text" name="panjang" placeholder="PANJANG" /></td>
	           <td><input type="text" name="lebar" placeholder="LEBAR" /></td>
	       </tr>
	       <tr>
		   <td><br />
		       <!--Button HITUNG-->
	               <label>
		          <input type="submit" name="submit" value="HITUNG">
		       </label>
		   </td>
		</tr>
	     </table>
	  </form>

	  <div id="hasil">
	     
	     <BR>Panjang = <BR>Lebar = <BR>Luas Bangun = 0<BR>Keliling Bangun = 0	  </div>
      </body>
</html>