wawandx

luas segitiga

Nov 6th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php
  2. // Start the session
  3. session_start();
  4. ?>
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <title>LUAS SEGITIGA</title>
  9. </head>
  10. <body>
  11. <center>
  12. <h2><u>LUAS SEGITIGA</u></h2>
  13. <form action="" method="POST">
  14. <table>
  15. <tr><td>ALAS</td><td>:</td><td><input type="text" name="alas"></td></tr>
  16. <tr><td>TINGGI</td><td>:</td><td><input type="text" name="tinggi"></td></tr>
  17. </table>
  18. <input type="submit" name="proses" value="proses"><input type="reset" name="hapus" value="hapus">
  19. </form>
  20. <?php
  21.  
  22. if(empty($_SESSION["alas"])){
  23. $alas=array();
  24. $tinggi=array();
  25. $proses=array();
  26. }
  27. if (isset($_POST["proses"])) {
  28. if(isset($_SESSION['alas'])){
  29. $alas=$_SESSION['alas'];
  30. $tinggi=$_SESSION['tinggi'];
  31. $proses=$_SESSION['proses'];
  32.  
  33. }
  34.  
  35. array_push($alas,$_POST['alas']);
  36. array_push($tinggi,$_POST['tinggi']);
  37. $proses1 = $_POST['alas']*$_POST['tinggi']/2;
  38. array_push($proses,$proses1);
  39.  
  40. $_SESSION["alas"]=$alas;
  41. $_SESSION["tinggi"]=$tinggi;
  42. $_SESSION["proses"]=$proses;
  43.  
  44. echo "<script>alert(".count($alas).")</script>";
  45.  
  46. if(count($alas)==5){
  47. $no = 1;
  48. echo "<center><table>";
  49. echo "<tr>
  50. <td>No</td>
  51. <td>Alas</td>
  52. <td>Tinggi</td>
  53. <td>Luas</td>
  54. <tr>";
  55. for($i=0; $i<5; $i++){
  56. echo "<tr>
  57. <td>".$no."</td>
  58. <td>".$alas[$i]."</td>
  59. <td>".$tinggi[$i]."</td>
  60. <td>".$proses[$i]."</td>
  61. <tr>";
  62. $no++;
  63. }
  64. echo "</table></center>";
  65. session_destroy();
  66. }
  67.  
  68. }
  69. ?>
  70. </center>
  71.  
  72. </body>
  73. </html>
Add Comment
Please, Sign In to add comment