Membuat Form Air Tanah Untuk Menu Insert Data Baru



Form_air_tanah.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Input Data Air Tanah</title>
</head>
<style>
body{ background:#000033; font:12px Arial; }
h1{ color:#0066FF }
form{ border:1px solid; width:60%; margin:10px; padding:15px 10px;
-moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; }
#rst{ color:yellow; font-size:16px; }
</style>
<body bgcolor="#000033">
  <table border="0" color="red" width="900" height="" BGCOLOR="#FFFFFF" align="center">
      <tr>
          <td>
              <?php
                include "headadmin.php";
              ?>
          </td>
      </tr>
      <tr>
           <td valign="top">
                <center>
                <h1>Tambah Data Potensi Air Tanah</h1>
    <form name="airtanah" id="airtanah" method="post" onsubmit="return cekNumerik()" action="save_airtanah.php">
                 <table border="0">
  <tr><td>id CAT</td>
        <td> : </td>
        <td> <input type="text" name="id_cat" size="20" maxlength="8" required="required"> </td>
  </tr>
   <tr><td>BWS/BBWS</td>
        <td> : </td>
        <td>
              <select name="id_bws" id="id_bws" onChange="pilih(this.value)">
              <option value="0" selected="selected">--Pilih Wilayah--</option>
              <?php
              include "koneksi.php";
              $query_limit=mysql_query("select * from wilayahbws");
              while($row=mysql_fetch_array($query_limit))
              {
              ?><option value="<?php  echo $row['id_bws']; ?>"><?php  echo $row['nm_bws']; ?></option><?php
              }
              ?>
              </select>
        </td>
  </tr>
  <tr><td>Nama CAT</td>
        <td> : </td>
        <td> <input type="text" name="nama_cat" size="36" maxlength="50" required="required"> </td>
  </tr>
  </tr>
  <tr><td>Debit Optimum  </td>
        <td> : </td>
        <td> <input type="text" name="debit_optimum" size="20" maxlength="9" >_liter/det </td>
  </tr>
  <tr><td>Potensi</td>
        <td> : </td>
        <td>
        <select name="potensi">
              <option value="Baik" selected="selected">Baik</option>
              <option value="Cukup Baik">Cukup Baik</option>
              <option value="Kurang">Kurang</option>
              </select> </td>
  </tr>
  <tr><td>Lokasi</td>
        <td> : </td>
        <td> <input type="text" name="lokasi" size="36" maxlength="50"> </td>
   </tr>
  <tr><td>Keterangan </td>
        <td> : </td>
        <td> <textarea  name="keterangan" cols="30" rows="5" maxlength="500"  size="20" ></textarea> </td>
  </tr>
  <tr>
  <td colspan="3" align="center"><br><input name="Submit" type="submit" value="Save" /></td>
  </tr>
 </table>
        </form>
          </td>
      </tr>
      <tr>
       <td colspan="2">
        <?php
          include "fotadmin.php";
        ?>
       </td>
       </tr>
  </table>
</body>
</html>

Keterangan :

<select name="id_bws" id="id_bws" onChange="pilih(this.value)">
              <option value="0" selected="selected">--Pilih Wilayah--</option>
              <?php
              include "koneksi.php";
              $query_limit=mysql_query("select * from wilayahbws");
              while($row=mysql_fetch_array($query_limit))
              {
              ?><option value="<?php  echo $row['id_bws']; ?>"><?php  echo $row['nm_bws']; ?></option><?php
              }
              ?>
              </select>

Merupakan link untuk menghubungkan tabel yang lainnya. Akan di bahas posting berikutnya
Hasil :


Script untuk menyimpan data dari form air tanah
save_airtanah.php
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <title>Admin</title>
</head>
<style>
body{ background:#000033; font:12px Arial; }
h1{ color:#0066FF }
form{ border:1px solid; width:60%; margin:10px; padding:15px 10px;
-moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; }
#rst{ color:white; font-size:16px; }
</style>
<body bgcolor="#000033">
  <table border="0" color="red" width="900" height="" BGCOLOR="#FFFFFF" align="center">
      <tr>
      <td width="30">
        <?php
          include "headadmin.php";
        ?>
      </td>
           <td valign="top">
                <center>
    <?php
     $id_bws = $_POST['id_bws'];
     $id_cat = $_POST['id_cat'];
     $nama_cat = $_POST['nama_cat'];
     $debit_optimum = $_POST['debit_optimum'];
     $potensi = $_POST['potensi'];
       $lokasi = $_POST['lokasi'];
       $keterangan = $_POST['keterangan'];
     //koneksi database
     include "koneksi.php";
    $query = "insert into airtanah set id_bws='$id_bws', id_cat='$id_cat', nama_cat='$nama_cat', debit_optimum='$debit_optimum',
    potensi='$potensi', lokasi='$lokasi', keterangan='$keterangan'";
    $hasil = mysql_query($query);
    if($hasil){
     echo "Data Air Tanah baru sudah di simpan";
    }else {
     echo "Error! gagal menyimpan data Air Tanah:".mysql_error();
    }
                echo"<li><font color=RED><a href=airtanah.php>Lihat data </a></font></li>"
   ?>
          </td>
      </tr>
      <tr>
       <td >
        <?php
          include "footeradmin.php";
        ?>
       </td>
       </tr>
       </table>
</body>
</html>

Sebenarnya masih ada menu edit. Tapi karena terlalu panjang maka di buat dalam postingan lain. Cek di manipulasi edit data

Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment