Advertisement
ferdhika31

Keren Simple

Dec 13th, 2014
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <form action="" method="post">
  2. <h4>PROGRAM TARIF BUS</h4>
  3. Masukkan pilihan (1-3) <input type="text" name="pilihan" placeholder='0'>
  4. <br>
  5. Masukkan jumlah penumpang <input type="text" name="jumlah" placeholder='0'>
  6. <br>
  7. <input type="submit" name="hitung" value="Hitung">
  8. <br><br>
  9. <?php
  10. if (isset($_POST['hitung'])) {
  11.  
  12. $pilihan = $_POST['pilihan'];
  13. $jumlah = $_POST['jumlah'];
  14. $harga = array(0,100000,150000,200000);
  15.  
  16. if (($pilihan == 1) || ($pilihan == 2) || ($pilihan == 3))
  17. {
  18. $hasil = $harga[$pilihan] * $jumlah;
  19. } else {
  20. $hasil = 0;
  21. }
  22. }
  23. ?>
  24. Maka jumlah harga adalah: <b><?php echo isset($hasil) ? $hasil : '0' ?></b>
  25. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement