Tugas 3 (Web Programing I)

Input dan Output program pembelian Cat di toko bagunan.


  • Form Input

<!DOCTYPE html>
<html>
<head>
 <title>Tampilan Input Toko Cat</title>
</head>
<body>
 <form action="Tugas3output.php" method="post">
  <table>
   <tr>
    <th><h4>TOKO CAT GUNA BANGUN JAYA</h4></th>
   </tr>
   <tr>
    <td>Nama Customer</td>
    <td>:</td>
    <td><input type="text" name="nama"></td>
   </tr>
   <tr>
    <td>Alamat</td>
    <td>:</td>
    <td><input type="text" name="alamat"></td>
   </tr>
   <tr>
    <td>Jenis Cat</td>
    <td>:</td>
    <td><select name="jenis">
      <option></option>
      <option>MOWILEX</option>
      <option>DANAPAINT</option>
      <option>CATYLAC</option>
     </select>
    </td>
   </tr>
   <tr>
    <td>Warna Cat</td>
    <td>:</td>
    <td>
     <input type="radio" name="warna" value="Merah">Merah
     <input type="radio" name="warna" value="Biru">Biru
     <input type="radio" name="warna" value="Kuning">Kuning
    </td>
   </tr><tr>
    <td>Jumlah Beli</td>
    <td>:</td>
    <td><input type="text" name="jumlah"></td>
   </tr>
  </table>

  <br/>
  <input type="submit" value="Hitung"><input type="reset" value="Batal">
 </form>
</body>
</html>




  • Output

<!DOCTYPE html>
<html>
<head>
 <title>Tampilan Output Toko Cat</title>
</head>
<body>
 <?php
 $nama = $_POST['nama'];
 $alamat = $_POST['alamat'];
 $jenis = $_POST['jenis'];
 $warna = $_POST['warna'];
 $jumlah = $_POST['jumlah'];

 switch ($jenis) {
  case 'MOWILEX': $jns = 20000;
   break;
  case 'DANAPAINT': $jns = 30000;
   break;
  case 'CATYLAC': $jns = 40000;
   break;
  default: $jns = "Tak ada jenis cat";
 }

 $total =  $jns*$jumlah;
 if ($jumlah >= 5) {
  $diskon = $total/100*5;
 }
 elseif ($jumlah >= 10) {
  $diskon = $total/100*10;
 }
 else{
  $diskon = 0;
 }

 $bayar = $total-$diskon;
 ?>

 <table>
  <tr>
   <th>TOKO CAT GUNA BANGUN JAYA</th>
  </tr>
  <tr>
   <td colspan="3" style="border-top: 1px dashed #000"></td>
  </tr>
  <tr>
   <td>Nama Customer</td>
   <td>:</td>
   <td><?php echo $nama; ?></td>
  </tr>
  <tr>
   <td>Alamat</td>
   <td>:</td>
   <td><?php echo $alamat; ?></td>
  </tr>
  <tr>
   <td>Jenis Cat</td>
   <td>:</td>
   <td><?php echo $jenis; ?></td>
  </tr>
  <tr>
   <td>Warna</td>
   <td>:</td>
   <td><?php echo $warna; ?></td>
  </tr>
  <tr>
   <td>Harga</td>
   <td>:</td>
   <td style="padding-left: 100px"><?php echo "Rp. ",$jns; ?></td>
  </tr>
  <tr>
   <td>Jumlah Beli</td>
   <td>:</td>
   <td><?php echo $jumlah; ?></td>
  </tr>
  <tr>
   <td colspan="3" style="border-top: 1px dashed #000"></td>
  </tr>
  <tr>
   <td>Total Harga</td>
   <td>:</td>
   <td style="padding-left: 100px"><?php echo "Rp. ",$total; ?></td>
  </tr>
  <tr>
   <td>Diskon</td>
   <td>:</td>
   <td style="padding-left: 100px"><?php echo "Rp. ",$diskon; ?></td>
  </tr>
  <tr>
   <td colspan="3" style="border-top: 1px dashed #000"></td>
  </tr>
  <tr>
   <td>Total Bayar</td>
   <td>:</td>
   <td style="padding-left: 100px"><?php echo "Rp. ",$bayar; ?></td>
  </tr>
  <tr>
   <td colspan="3" style="border-top: 1px dashed #000"></td>
  </tr>
 </table>
 <br/>
 <a href="Tugass3input.php">Kembali</a>
</body>
</html>



Selesai....

Komentar

Postingan populer dari blog ini

Tugas Membuat Web Perpustakaan dengan CSS dan HTML

Menghitung Volume Kubus Menggunakan Operator Aritmatika & String

Resume Jaringan Komputer