Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <!-- Create by KhalidLubis !-->
- <title>Kalkulator Infosoft </title>
- </head>
- <body>
- <?php
- if(isset($_POST['hitung']))
- {
- $bil1 = $_POST['bil1'];
- $bil2 = $_POST['bil2'];
- $operasi = $_POST ['operasi'];
- switch ($operasi)
- {
- case 'tambah';
- $hasil = $bil1+$bil2;
- break;
- case 'kurang';
- $hasil = $bil1-$bil2;
- break;
- case 'kali';
- $hasil = $bil1*$bil2;
- break;
- case 'bagi';
- $hasil = $bil1/$bil2;
- break;
- }
- }
- ?>
- <div class="Kalkulator">
- <h2>kalkulator online</h2>
- <form method="post" action="index.php">
- <input type="text" name="bil1" autocomplete="off" placeholder="Masukkan Bilangan Pertama"></br>
- <input type="text" name="bil2" autocomplete="off" placeholder="Masukkan Bilangan Kedua">
- <select class="opt" name="operasi">
- <option value="tambah">+</option>
- <option value="kurang">-</option>
- <option value="kali">*</option>
- <option value="bagi">/</option>
- </select>
- <button type="submit" name="hitung" value="Hitung">Hitung</button>
- </form>
- <?php if(isset($_POST['hitung'])){ ?>
- <input type="text" value="<?php echo $hasil; ?>">
- <?php } else { ?>
- <input type="text" value="0">
- <?php } ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement