Senin, 05 November 2012

PHP (Latihan 18)

Posted by Unknown On Senin, November 05, 2012 | No comments
Gambar 1.0
Ketika Button Proses Diclick Maka Tampil Seperti Gambar 2.0
Gambar 2.0
Ketika Click "Input Pemesanan" Maka Tampil Seperti Gambar 1.0

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


<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Pemesanan Tiket Kereta Api</title>
</head>
<body style="background-image:url(keretaapi.jpg)">
<form action="cetak.php" method="post">
<h1><center><font face="Algerian" color="#B0171F">Pemesanan Tiket Kereta Api "ABC"</h1></center></font>
<hr width=100% size=4 color="white" />
<br>
<table border="1" width="500" align="center" cellspacing="1" >
<tr>
    <td colspan="2" align="center"><font color="white"><b>Input Pemesanan</td></b></font>
</tr>
<tr>
     <td width="200"><font color="white">Kode Petugas</td></font>
     <td><select name="kope">
                 <option>--Click Here--</option>
                 <option value="101001">101001</option>
                 <option value="101002">101002</option>
                 <option value="101003">101003</option>
                 </select></td>
</tr>
<tr>
    <td><font color="white">Kode Kereta</td></font>
    <td><select name="koti">
                <option>--Click Here--</option>
                <option value="SEN01">SEN01</option>
                <option value="MUT02">MUT02</option>
                <option value="BIM03">BIM03</option>
                </select></td>
</tr>
<tr>
    <td><font color="white">Nama Pemesan</td></font>
    <td><input type="text" name=nama size=30></td>
</tr>
<tr>
    <td valign=top><font color="white">Alamat Pemesan</td></font>
    <td><textarea name="alamat" rows=5 cols=30></textarea></td>
</tr>
<tr>
    <td><font color="white">Hari Keberangkatan</td></font>
    <td><select name="hari"</td>
                <option>--Click Here--</option>
                <option value="Senin">Senin</option>
                <option value="Selasa">Selasa</option>
                <option value="Rabu">Rabu</option>
                <option value="Kamis">Kamis</option>
                <option value="Jum'at">Jum'at</option>
                <option value="Sabtu">Sabtu</option>
                <option value="Minggu">Minggu</option>
                </select></td>
</tr>
<tr>
    <td><font color="white">Jam Keberangkatan</td></font>
    <td><select name="jam"</td>
                <option>--Click Here--</option>
                <option value="09.00">09.00</option>
                <option value="11.30">11.30</option>
                <option value="15.00">15.00</option>
                <option value="17.30">17.30</option>
                <option value="20.00">20.00</option>
                <option value="21.50">21.50</option>
                </select></td>
</tr>
<tr>
    <td><font color="white">Tujuan</td></font>
    <td><select name="tujuan">
                <option>--Click Here--</option>
                <option value="Jakarta-Bandung">Jakarta-Bandung</option>
                <option value="Jakarta-Semarang">Jakarta-Semarang</option>
                <option value="Jakarta-Surabaya">Jakarta-Surabaya</option>
                </select></td>
</tr>
<tr>
    <td><font color="white">Kelas</td></font>
    <td><b><input type="radio" value="Ekonomi" name="kelas">Ekonomi
        <input type="radio" value="Bisnis" name="kelas">Bisnis
        <input type="radio" value="VIP" name="kelas">VIP
        </td></b>
</tr>
<tr>
    <td><font color="white">Jumlah Tiket</td></font>
    <td><input type="text" size=4 name=jumbel><b><font color="white"> Tiket</td></font></b>
               <tr>
                   <td border="0" align="Center" colspan="2">
                       <input type="submit" value="Proses"><input type="reset" value="Cancel">
                   </td>
               </tr>
</table>
<br><br><br><br><br><br><br><br><br>
<hr width=100% size=4 color="white" />
<center><h5><font color="#B0171F" face="algerian">Copyright &copy 2012 | Powered By Adam Khamarullah</center></h5></font>
</form>
</body>
</html>

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


<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Pemesanan Tiket Kereta Api</title>
</head>
<body bgcolor="gray">
<?php
$nama=$_POST['nama'];
$alamat=$_POST['alamat'];
if($koti=='SEN01')
{
    $naker="Senja Utama";
}
elseif($koti=='MUT02')
{
    $naker="Mutiara Timur";
}
else
{
    $naker="Bima Kencana";
}

if($kope=='101001')
{
    $napet="Muhammad Dimas";
}
elseif($kope='101002')
{
    $napet="Angga Kurniawan";
}
else
{
    $napet="Bowo Setiawan";
}

if($tujuan=='Jakarta-Bandung')
{
    if($kelas=='Ekonomi')
    {
        $harga=100000;
    }
    elseif($kelas='Bisnis')
    {
        $harga=200000;
    }
    else
    {
        $harga=300000;
    }
}
elseif($tujuan=='Jakarta-Semarang')
{
    if($kelas=='Ekonomi')
    {
        $harga=200000;
    }
    elseif($kelas=='Bisnis')
    {
        $harga=300000;
    }
    else
    {
        $harga=400000;
    }
}
else
{
    if($kelas=='Ekonomi')
    {
        $harga=300000;
    }
    elseif($kelas=='Bisnis')
    {
        $harga=400000;
    }
    else
    {
        $harga=500000;
    }
}

if($hari=='Sabtu')
{
    $tambah=10000;
}
elseif($hari=='Minggu')
{
    $tambah=15000;
}
else
{
    $tambah=0;
}

$jam=$_POST['jam'];
$jumbel=$_POST['jumbel'];
$total=($harga*$jumbel)+$tambah;
?>
<center><h1><font face="Algerian" color="#B0171F">Pemesanan Tiket Kereta Api "ABC"</center></h1></font>
<hr width=100% size=4 color=white />
<table border="0" align="center">
<tr><td>
<table border="2" width="300" align="left"  cellspacing="1"></tr>
<tr><td><b>Kode Petugas</td></b><td><?=$kope?></td></tr>
<tr><td><b>Nama Petugas</td></b><td><?=$napet?></td></tr>
<br>
</table>
<table border="0" align="center">
<br>
<tr><td>
<br>
<table border="2" width="500" align="center" cellspacing="1">
<tr><td><b>Kode Kereta</td></b><td><?=$koti?></td></tr>
<tr><td><b>Nama Kereta</td></b><td><?=$naker?></td></tr>
<tr><td><b>Nama Pemesan</td></b><td><?=$nama?></td></tr>
<tr><td><b>Alamat Pemesan</td></b><td><?=$alamat?></td></tr>
<tr><td><b>Hari Keberangkatan</td></b><td><?=$hari?></td></tr>
<tr><td><b>Jam Keberangkatan</td></b><td><?=$jam?></td></tr>
<tr><td><b>Kelas</td></b><td><?=$kelas?></td></tr>
<tr><td><b>Tujuan</td></b><td><?=$tujuan?></td></tr>
<tr><td><b>Jumlah Tiket</td></b><td><?=$jumbel?></td></tr>
<tr><td border="0" align="center" colspan="2"><b>Total Biaya</tr></td></b>
<tr><td><b>Harga</td></b><td><?=$harga?></td></tr>
<tr><td><b>Tambah</td></b><td><?=$tambah?></td></tr>
<tr><td><b>Total</td></b><td><?=$total?></td></tr>
<tr><td border="0" align="center" colspan="2"><h4><a href="index.html">Input Pemesanan</tr></td></h4></a>
</table>
<pre>
<h5><i> *NB:Hari Sabtu Dikenakan Tambahan Biaya Sebesar Rp.10000
     Hari Minggu Dikenakan Tambahan Biaya Sebesar Rp.15000</h5></i></pre>
    <br>
<center>
<font face="Algerian" color="#B0171F"><h4>Terima Kasih</h4>
<h4>Semoga Selamat Sampai Tujuan</h4></center></font>
</body>
</html>

0 komentar:

Posting Komentar

Blog Archive

Blogroll