Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Start the session
- session_start();
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>LUAS SEGITIGA</title>
- </head>
- <body>
- <center>
- <h2><u>LUAS SEGITIGA</u></h2>
- <form action="" method="POST">
- <table>
- <tr><td>ALAS</td><td>:</td><td><input type="text" name="alas"></td></tr>
- <tr><td>TINGGI</td><td>:</td><td><input type="text" name="tinggi"></td></tr>
- </table>
- <input type="submit" name="proses" value="proses"><input type="reset" name="hapus" value="hapus">
- </form>
- <?php
- if(empty($_SESSION["alas"])){
- $alas=array();
- $tinggi=array();
- $proses=array();
- }
- if (isset($_POST["proses"])) {
- if(isset($_SESSION['alas'])){
- $alas=$_SESSION['alas'];
- $tinggi=$_SESSION['tinggi'];
- $proses=$_SESSION['proses'];
- }
- array_push($alas,$_POST['alas']);
- array_push($tinggi,$_POST['tinggi']);
- $proses1 = $_POST['alas']*$_POST['tinggi']/2;
- array_push($proses,$proses1);
- $_SESSION["alas"]=$alas;
- $_SESSION["tinggi"]=$tinggi;
- $_SESSION["proses"]=$proses;
- echo "<script>alert(".count($alas).")</script>";
- if(count($alas)==5){
- $no = 1;
- echo "<center><table>";
- echo "<tr>
- <td>No</td>
- <td>Alas</td>
- <td>Tinggi</td>
- <td>Luas</td>
- <tr>";
- for($i=0; $i<5; $i++){
- echo "<tr>
- <td>".$no."</td>
- <td>".$alas[$i]."</td>
- <td>".$tinggi[$i]."</td>
- <td>".$proses[$i]."</td>
- <tr>";
- $no++;
- }
- echo "</table></center>";
- session_destroy();
- }
- }
- ?>
- </center>
- </body>
- </html>
Add Comment
Please, Sign In to add comment