Rabu, 10 Oktober 2012

PHP (Latihan 12)

Posted by Unknown On Rabu, Oktober 10, 2012 | No comments
Gambar 1.0
Ketika Button Cetak Diclick Maka Akan Tampil Seperti Gambar 2.0
Gambar 2.0
Ketika Click Kembali Maka Akan Tampil Seperti Gambar 1.0

Coding/Listing Gambar 1.0 (Simpan Dengan Nama latihan12.html) :


<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Latihan 12</title>
</head>
<body style="background-image:url(http://localhost/Adam/Background%20Blogger/abstract-white_00345294.jpg)">
<form action="cat.php" method="post">
<center><h1>Toko Cat Bangun Jaya</center></h1>
<hr width=100% size=4 color=red />
<pre>
     Nama Customer   : <input type="text" size=35 name=nama>
     Alamat          : <input type="text" size=50 name=alamat>
     Jenis Cat       : <select name=jenis>
                       <option>--Pilih Cat--</option>
                       <option value=Mowilex>Mowilex</option>
                       <option value=Danapaint>Danapaint</option>
                       <option value=Catylac>Catylac</option>
                       </select>
     Warna Cat       : <input type="radio" name=warna value=Merah>Merah
                       <input type="radio" name=warna value=Hijau>Hijau
                       <input type="radio" name=warna value=Kuning>Kuning
     Jumlah Beli     : <input type="text" size=3 name=jumbel>
<br>
     <input type="submit" value=Cetak><input type="reset" value=Batal>
</form>
</body>
</html>

Coding/Listing Gambar 2.0 (Simpan Dengan Nama cat.php) :


<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Latihan 12</title>
</head>
<body style="background-image:url(http://localhost/Adam/Background%20Blogger/abstract-white_00345294.jpg)">
<?
$nama=$_POST['nama'];
$alamat=$_POST['alamat'];
if($jenis=='Mowilex')
{
    $harga=25000;
}
else
if($jenis=='Danapaint')
{
    $harga=35000;
}
else
if($jenis=='Catylac')
{
    $harga=45000;
}
else
{
    $harga=0;
}

$warna=$_POST['warna'];
$total=$harga*$jumbel;
if($jumbel>=5)
{
    $diskon=0.05*$total;
}
else
if($jumbel>=10)
{
    $diskon=0.1*$total;
}
else
{
    $diskon=0;
}

$tobay=$total-$diskon;
?>
<center><h1>Toko Cat Bangun Jaya</center></h1>
<hr width=100% size=4 color=red />
<pre>
     Nama Customer   : <?=$nama?><br>
     Alamat          : <?=$alamat?><br>
     Jenis Cat       : <?=$jenis?><br>
     Warna           : <?=$warna?><br>
     Harga           : <?=$harga?><br>
     Jumlah Beli     : <?=$jumbel?><br>
     ---------------------------------------- (*
     Total Harga     : <?=$total?><br>
     Diskon          : <?=$diskon?><br>
     ---------------------------------------- (-
     Total Bayar     : <?=$tobay?></pre>
     <br>
<center><h3><a href="latihan12.html">Kembali</center></h3></a>
</body>
</html>

0 komentar:

Posting Komentar

Blog Archive

Blogroll