Form Dengan PHP

Tugas Pemrograman Web
Membuat Form Dengan PHP

Kali ini saya akan membahas tentang bagaimana cara membuat form pembayaran rekening air dengan menggunakan PHP. Berikut source code dan tampilan akhirnya.

1. Source Code

 <!DOCTYPE html>  
 <html>  
 <head>  
      <title>Pembayaran Rekening Air</title>  
 </head>  
 <style type="text/css">  
      body{  
           margin-top: 30px;  
           font-family: arial;  
           background: #cfcfcf;  
      }  
      #ins{  
           height: 25px;  
           width: 300px;  
           font-weight: bold;  
           font-size: 14px;  
           border: solid #937 1px;  
      }  
      #in{  
           height: 25px;  
           width: 50px;  
           font-weight: bold;  
           font-size: 14px;  
           border: solid #937 1px;  
      }  
      #sel{  
           height: 25px;  
           width: 100px;  
           font-weight: bold;  
           font-size: 14px;  
           border: solid #937 1px;  
      }  
      #sub{  
           background: #cb0051;  
           height: 25px;  
           width: 100px;  
           font-weight: bold;  
           font-size: 14px;  
           border: solid #937 1px;  
           color: #fff;  
      }  
      #sb{  
           color: #fff;  
           background: #cb0051;  
           height: 25px;  
           width: 100px;  
           font-weight: bold;  
           font-size: 14px;  
           border: solid #937 1px;  
      }  
      table{  
           background: #00664d;  
           border: solid #937 1px;  
           padding-left: 100px;  
           padding-right: 100px;  
           padding-bottom: 15px;  
           padding-top: 20px;  
      }  
 </style>  
 <body>  
 <form method="post" action="index.php">  
      <table align="center">  
           <tr>  
                <th colspan="2"><font size="5">Pembayaran Rekening Air</font><hr color="#f0c1c1" width="700"></th>  
           </tr>  
           <tr>  
                <th align="left">Nama</th>  
                <td><input id="ins" type="text" name="nama"></td>  
           </tr>  
           <tr>  
                <th align="left">No.KTP</th>  
                <td><input id="ins" type="text" name="noktp"></td>  
           </tr>  
           <tr>  
                <th align="left">Alamat</th>  
                <td><input id="ins" type="text" name="alamat"></td>  
           </tr>  
           <tr>  
                <th align="left">No.HP</th>  
                <td><input id="ins" type="text" name="nohp"></td>  
           </tr>  
           <tr>  
                <th align="left">Kode</th>  
                <td><select id="sel" name="kode">  
                     <option>-Pilih-</option>  
                     <option value="A1">A1</option>  
                     <option value="A2">A2</option>  
                     <option value="A3">A3</option>  
                     <option value="A4">A4</option>  
                </select></td>  
           </tr>  
           <?php  
           error_reporting(0);  
                $kode = $_POST['kode'];  
                $jp = $_POST['jp'];  
                $by = $_POST['by'];  
                $hp = $_POST['hp'];  
                     if ($kode == "A1") {  
                          $jp="Pelanggan Pabrik";  
                          $by="35000";  
                          $hp="1525";  
                     }  
                     else if ($kode == "A2") {  
                          $jp="Pelanggan Supermarket/Swalayan";  
                          $by="27900";  
                          $hp="1125";  
                     }  
                     else if ($kode == "A3") {  
                          $jp="Pelanggan Toko/Pasar";  
                          $by="21900";  
                          $hp="755";  
                     }  
                     else if ($kode == "A4") {  
                          $jp="Pelanggan Biasa/Normal";  
                          $by="17500";  
                          $hp="525";  
                     }  
           ?>  
           <tr>  
                <th align="left">Jenis Pelanggan</th>  
                <td><input id="ins" type="hidden" name="jp" value="<?php echo "$jp" ?>">  
                <input id="ins" disabled="disabled" value="<?php echo "$jp" ?>"> ></td>  
           </tr>  
           <tr>  
                <th align="left">Biaya Beban</th>  
                <td><input id="ins" type="hidden" name="by" value="<?php echo "$by" ?>">  
                <input id="ins" disabled="disabled" value="<?php echo "$by" ?>"> ></td>  
           </tr>  
           <tr>  
                <th align="left">Harga Per Kubik</th>  
                <td><input id="ins" type="hidden" name="hp" value="<?php echo "$hp" ?>">  
                <input id="ins" disabled="disabled" value="<?php echo "$hp" ?>"> ></td>  
           </tr>  
           <tr>  
                <th align="left">Pemakaian Air</th>  
                <td><input id="in" type="text" name="pemakaian">&nbsp;<b><font size="4">Kubik</font></b></td>  
           </tr>  
           <?php  
                $kode = $_POST['kode'];  
                $jp = $_POST['jp'];  
                $by = $_POST['by'];  
                $hp = $_POST['hp'];  
                $pemakaian = $_POST['pemakaian'];  
                $tot = $_POST['tot'];  
                $tot = $pemakaian*$hp+$by;  
           ?>  
           <tr>  
                <th align="left">Total Pembayaran</th>  
                <td><input id="ins" type="hidden" name="tot" value="<?php echo "$tot" ?>">  
                <input id="ins" disabled="disabled" value="<?php echo "$tot" ?>"></td>  
           </tr>  
           <tr>  
                <td colspan="2" height="50">  
                <input id="sub" type="submit" name="submit" value="Proses">&nbsp;&nbsp;&nbsp;  
                <input id="sb" type="reset" value="Hapus"></td>  
           </tr>  
           <tr>  
                <td colspan="2" align="right"><font color="#f0c1c1">Copyright &copy; Yuki YR</font></td>  
           </tr>  
      </table>  
 </form>  
 </body>  
 </html>  

2. Tampilan Akhir





Kalian juga bias mencobanya sendiri lo, dengan mengakses yukiyr.cucicuciku.com. Selamat mencoba! Sekian, semoga bermanfaat.

Komentar

Postingan populer dari blog ini

Tugas Membuat Jam Digital

Codeigniter "Toko Buah"

Personal Web