<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <!–//mobile responsive–>
<meta http-equiv=”X-UA-Compatible” content=”ie=edge”>
<title>Document</title>
</head>
<body>

[insert_php]
 if (!empty($_POST)){
 $p=$_POST['panjang']; //form panjang
 $t=$_POST['tinggi']; //form tinggi
 $konstanta = [ //konstanta
 "batu_bata"=> 70, 
 "pasir"=>0.045,
 "pondasi"=>0.225,
 "semen"=>0.166
 ];
 $r_batubata=$p*$t*$konstanta['batu_bata']; //rumusbata
 $r_pasir =$p*$t*$konstanta['pasir']; //rumuspasir
 $r_pondasi=$p*$konstanta['pondasi']; //rumuspondasi
 $r_semen=$p*$t*$konstanta['semen']; //rumussemen
 ?> 
 <table border=1> <!--Tabel-->
 <tr>
 <th>No</th><th>Perhitungan Keb. Jumlah</th><th>Satuan</th><th>Total</th>
 </tr>
 <tr><td>1</td><td>Batu Bata</td><td>Buah</td><td><?=$r_batubata?></td></tr>
 <tr><td>2</td><td>Pasir</td><td>m3</td><td><?=$r_pasir?></td></tr>
 <tr><td>3</td><td>Batu Pondasi</td><td>m3</td><td><?=$r_pondasi?></td></tr>
 <tr><td>4</td><td>Sak Semen</td><td>sak</td><td><?=$r_semen?></td></tr>
 </table>
 <
[/insert_php]
} ?>
 <form method="post" action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>>
 <table> 
 <tr>
 <td>Panjang</td><td>:</td><td><input type="text" name="panjang"/></td>
 </tr>
 <tr>
 <td>Tinggi</td><td>:</td><td><input type="text" name="tinggi"/></td>
 </tr>
 <tr>
 <td></td><td></td><td><button type="submit">Hitung</button></td>
 </tr>
 </table>
 </form> 
 
</body>
<script>
 function myfunc(){
 window.location.reload(true); 
 }
</script>
</html>