Advertisement
Guest User

kalkulatorbefore

a guest
Jul 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.84 KB | None | 0 0
  1.    
  2. Data hosted with ? by Pastebin.com - Download Raw - See Original
  3.  
  4. <html>
  5. <head>
  6.     <title>Membuat Kalkulator Sederhana Dengan PHP | www.malasngoding.com</title>
  7.     <style type="text/css">
  8.         body{
  9.     background: #F2F2F2;
  10.     font-family: sans-serif;
  11. }
  12.  
  13. .kalkulator{
  14.     width: 335px;
  15.     background: #2F495A;
  16.     margin: 100px auto;
  17.     padding: 10px 20px 50px 20px;
  18.     border-radius: 5px;
  19.     box-shadow: 0px 10px 20px 0px #D1D1D1;
  20. }
  21.  
  22. .bil{
  23.     width: 300px;
  24.     margin: 5px;
  25.     border: none;
  26.     font-size: 16pt;
  27.     border-radius: 5px;
  28.     padding: 10px;
  29. }
  30.  
  31. .opt{
  32.     font-size: 16pt;
  33.     border: none;
  34.     width: 215px;
  35.     margin: 5px;
  36.     border-radius: 5px;
  37.     padding: 10px;
  38. }
  39.  
  40. .tombol{
  41.     background: #EC5159;
  42.     border-top: none;
  43.     border-right: none;
  44.     border-left: none;
  45.     border-radius: 5px;
  46.     padding: 10px 20px;
  47.     color: #eee;
  48.     font-size: 15pt;
  49.     border-bottom:4px solid #BF3D3D;
  50. }
  51.  
  52. .brand{
  53.     color: #eee;
  54.     font-size: 11pt;
  55.     float: right;
  56.     text-decoration: none;
  57.     margin: 12px;
  58. }
  59.  
  60. .judul{
  61.     text-align: center;
  62.     color: #eee;
  63.     font-weight: normal;
  64. }
  65.  
  66.     </style>
  67. </head>
  68. <body>
  69.     <?php
  70.    if(isset($_POST['hitung'])){
  71.        $bil1 = $_POST['bil1'];
  72.        $bil2 = $_POST['bil2'];
  73.        $operasi = $_POST['operasi'];
  74.        switch ($operasi) {
  75.            case 'tambah':
  76.                $hasil = $bil1+$bil2;
  77.            break;
  78.            case 'kurang':
  79.                $hasil = $bil1-$bil2;
  80.            break;
  81.            case 'kali':
  82.                $hasil = $bil1*$bil2;
  83.            break;
  84.            case 'bagi':
  85.                $hasil = $bil1/$bil2;
  86.            break;        
  87.        }
  88.    }
  89.    ?>
  90.  
  91.     <div class="kalkulator">
  92.         <h2 class="judul">KALKULATOR</h2>
  93.         <a class="brand" href="https://www.malasngoding.com">www.malasngoding.com</a>
  94.         <form method="post" action="index.php">        
  95.             <input type="text" name="bil1" class="bil" autocomplete="off" placeholder="Masukkan Bilangan Pertama">
  96.             <input type="text" name="bil2" class="bil" autocomplete="off" placeholder="Masukkan Bilangan Kedua">
  97.             <select class="opt" name="operasi">
  98.                 <option value="tambah">+</option>
  99.                 <option value="kurang">-</option>
  100.                 <option value="kali">x</option>
  101.                 <option value="bagi">/</option>
  102.             </select>
  103.             <input type="submit" name="hitung" value="Hitung" class="tombol">                                          
  104.         </form>
  105.         <?php if(isset($_POST['hitung'])){ ?>
  106.             <input type="text" value="<?php echo $hasil; ?>" class="bil">
  107.         <?php }else{ ?>
  108.             <input type="text" value="0" class="bil">
  109.         <?php } ?>        
  110.     </div>
  111. </body>
  112.  
  113.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement