Advertisement
urutehe1

full

Sep 16th, 2019
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4.     <!-- Create by KhalidLubis !-->
  5.     <title>Kalkulator Infosoft </title>
  6.    
  7.     </head>
  8.     <body>
  9.         <?php
  10.         if(isset($_POST['hitung']))
  11.         {
  12.             $bil1 = $_POST['bil1'];
  13.             $bil2 = $_POST['bil2'];
  14.             $operasi = $_POST ['operasi'];
  15.             switch ($operasi)
  16.             {
  17.                 case 'tambah';
  18.                     $hasil = $bil1+$bil2;
  19.                 break;
  20.                 case 'kurang';
  21.                     $hasil = $bil1-$bil2;
  22.                 break;
  23.                 case 'kali';
  24.                     $hasil = $bil1*$bil2;
  25.                 break;
  26.                 case 'bagi';
  27.                     $hasil = $bil1/$bil2;
  28.                 break;
  29.             }
  30.         }
  31.         ?>
  32.         <div class="Kalkulator">
  33.             <h2>kalkulator online</h2>
  34.             <form method="post" action="index.php">
  35.                 <input type="text" name="bil1" autocomplete="off" placeholder="Masukkan Bilangan Pertama"></br>
  36.                 <input type="text" name="bil2" autocomplete="off" placeholder="Masukkan Bilangan Kedua">
  37.                 <select class="opt" name="operasi">
  38.                     <option value="tambah">+</option>
  39.                     <option value="kurang">-</option>
  40.                     <option value="kali">*</option>
  41.                     <option value="bagi">/</option>
  42.                 </select>
  43.                 <button type="submit" name="hitung" value="Hitung">Hitung</button>
  44.             </form>
  45.             <?php if(isset($_POST['hitung'])){ ?>
  46.                 <input type="text" value="<?php echo $hasil; ?>">
  47.                 <?php } else { ?>
  48.                     <input type="text" value="0">
  49.                 <?php } ?>
  50.         </div>
  51. </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement