mysql_connect("localhost", "", "");
mysql_select_db("");
$kode = htmlspecialchars($_POST['kode']);
$nama = htmlspecialchars($_POST['idProp']);
$user = htmlspecialchars($_POST['namaPropinsi']);
$password = htmlspecialchars($_POST['lokasi']);
$harga = htmlspecialchars($_POST['harga']);
$cek = mysql_num_rows(mysql_query("SELECT kode, lokasi FROM lokasi where kode = '$kode'"));
if ($cek > 0 ){
echo "<h1>Code of Address has been exist</h1>";
echo "<br>";
}else {
$cek2 = mysql_num_rows(mysql_query("select kode, lokasi from lokasi where lokasi = '$password'"));
if ($cek2>0){
echo "<h1>Address has been exist</h1>";
echo "<br>";
}else{
$cek3 = mysql_num_rows(mysql_query("select idProp,namaPropinsi from propinsi where idProp ='$nama'"));
if ($cek3>0){
echo "<h1>Code of Location has been exist</h1>";
echo "<br>";
}else{
$sql = "INSERT INTO propinsi VALUES('$nama', '$user' )";
mysql_query($sql) or die ('Failed');
$sql = "insert into lokasi values ('$kode','$password','$user','$harga','$nama')";
mysql_query($sql) or die ('Failed');
echo "<h1>Register Success</h1>";
echo "<br>";
}
}
}
<?php
mysql_connect ('localhost','','');
mysql_select_db ('');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tipedata = $_POST['tipe'];
$id = $_POST['id'];
switch($tipedata){
case 'lokasi':
$sql='SELECT kode,lokasi,namaPropinsi FROM '.$tipedata.' WHERE idProp = "'.$id.'" ORDER BY lokasi ASC';break;
case 'propinsi':
$sql='SELECT idProp,namaPropinsi FROM '.$tipedata.' ORDER BY namaPropinsi ASC';break;
}
$kueri=mysql_query($sql);
echo '<option value=""></option>';
while($row=mysql_fetch_object($kueri)){
echo '<option value="'.$row->idProp.'">';
switch($tipedata){
case 'lokasi':
echo $row->lokasi;break;
case 'propinsi':
echo $row->namaPropinsi;break;
}
echo '</option>';
}
}
?>
<script language="javascript">
function Load(data,primid){
$('#loading'+data).empty().append('<img src="img/ajax-loader.gif"/>');
$.post("lo.php",{tipe:data,id:primid},
function(result){
$('#cb'+data).html(result);
$('#loading'+data).empty();
}
);
}
$(function(){
Load('propinsi',0);
$('#cbpropinsi').change(
function(){
if($('#cbpropinsi option:selected').val() !=''){
Load('lokasi',$('#cbpropinsi option:selected').val());
}
}
);
});
<tr title="Required">
<td><b>Location</b><span class="required">*</span></td>
<td>:</td>
<td><select name="lokasi" id="cbpropinsi" style="width:311px"></select></td>
</tr>
<tr title="Required">
<td><b>Address of Location</b><span class="required">*</span></td>
<td>:</td>
<td><select name="propinsi" id="cblokasi" style="width:311px"></select></td>
</tr>
<form name="FLaporan" method="post" action="delete-banyak.php" onSubmit="return confirm('Hapus data terpilih?')">
<table class="table" cellspacing="0" width="100%">
<thead>
<tr>
<th scope="col" style="text-align:center;">No</th>
<th align="center"> </th>
<th scope="col" style="text-align:center;">Code of Transaction</th>
<th scope="col" style="text-align:center;">Mitra Name</th>
<th scope="col" style="text-align:center;">Address</th>
<th scope="col" style="text-align:center;">Building</th>
<th scope="col" style="text-align:center;">Address of Building</th>
<th scope="col" style="text-align:center;">Number of Vechile</th>
<th scope="col" style="text-align:center;" class="table-actions">Actions</th>
</tr>
</thead>
<?php
$batas = 5;
$halaman = $_GET['halaman'];
$posisi = null;
if(empty($halaman)){
$posisi = 0;
$halaman = 1;
}else{
$posisi = ($halaman-1)* $batas;
}
mysql_connect ("localhost", "", "");
mysql_select_db ("");
$query = "SELECT * FROM parkir LIMIT $posisi, $batas";
$result = mysql_query($query) or die ('error');
$no = 1;
while ($data = mysql_fetch_array($result)){
?>
<tbody>
<td><?php echo $no ?> </td>
<td align="center">
<input type="checkbox" name="item[]" id="item[]" value="<?php echo $data->tagihan_nomor?>" /></td>
<td><?php echo $data['tagihan_nomor']; ?> </td>
<td><?php echo $data['nama_mitra']; ?> </td>
<td><?php echo $data['alamat']; ?></td>
<td><?php echo $data['lokasi']; ?> </td>
<td><?php echo $data['alamat_lokasi']; ?> </td>
<td><?php echo $data['nomor_polisi']; ?></td>
<td class="table-actions">
<a href="http://localhost/ABMS/parking_process_result.php?kode=<?php echo $data['tagihan_nomor']?>" title="Transaction" class="with-tip"><img src="images/icons/fugue/pencil.png" width="16" height="16"></a>
</td>
</tr>
<?php
$no++;
}
?>
</table>
<?php
$sql_paging = mysql_query("SELECT tagihan_nomor from parkir");
$jmldata = mysql_num_rows($sql_paging);
$jumlah_halaman = ceil($jmldata / $batas);
echo "page: ";
for ($i = 1; $i <= $jumlah_halaman; $i++)
if ($i !=$halaman) {
echo "<a href=parking_process.php?halaman=$i>$i</a>|";
}else{
echo "<b>$i</b>|";
}
mysql_close();
?>
</a></p>
</form>
<?php
if($_GET) {
$nama = $_POST['nama'];
$email = $_POST['email'];
$telp = $_POST['telp'];
$berat = $_POST['berat'];
$jumlah = $_POST['jumlah'];
$tanggal = $_POST['tanggal'];
$alamat = $_POST['alamat'];
$error = array();
if(empty($nama)){
$error['nama'] = 'NAMA tidak boleh kosong';
}
if(empty($email)){
$error['email'] = 'EMAIL tidak boleh kosong';
}
if(empty($telp)){
$error['telp'] = 'No.TELP tidak boleh kosong';
}
if(empty($berat)){
$error['berat'] = 'BERAT BARANG tidak boleh kosong';
}
else if ($berat < 5 == $jumlah = 5){
$error['berat'] ='BERAT BARANG tidak sesuai';
}
if(empty($jumlah)){
$error['jumlah'] = 'JUMLAH BARANG tidak boleh kosong';
}
else if ($berat > 5 == $jumlah >= 1){
$error['jumlah'] ='JUMLAH BARANG tidak sesuai';
}
if(empty($tanggal)){
$error['tanggal'] = 'TANGGAL tidak boleh kosong';
}
if(empty($alamat)){
$error['alamat'] = 'ALAMAT tidak boleh kosong';
}
if(empty($error)){
//prosess data
}
}
?>
<form name="PickUp" method="post" action="phptest2.php">
<table width="75%" border="1" align="center">
<tr>
<td width="25%">NAMA</td>
<td width="50%"><div style="color:red;">
<input name="nama" id="nama" type="text" size="33" value="<?php echo isset($_POST['nama']) ? $_POST['nama'] : '';?>"/>
<?php echo isset($error['nama']) ? $error['nama'] : '';?></div>
</td>
</tr>
<tr>
<td width="15%">EMAIL</td>
<td width="35%"><div style="color:red;">
<input name="email" id="email" type="text" size="33" value="<?php echo isset($_POST['email']) ? $_POST['email'] : '';?>"/>
<?php echo isset($error['email']) ? $error['email'] : '';?></div>
</td>
</tr>
<tr>
<td width="15%">TELP</td>
<td width="35%"><div style="color:red;">
<input name="telp" id="telp" type="text" size="33" value="<?php echo isset($_POST['telp']) ? $_POST['telp'] : '';?>"/>
<?php echo isset($error['telp']) ? $error['telp'] : '';?></div>
</td>
</tr>
<tr>
<td width="15%">BERAT BARANG</td>
<td width="35%"><div style="color:red;">
<input name="berat" id="berat" type="text" size="33" value="<?php echo isset($_POST['berat']) ? $_POST['berat'] : '';?>"/>
<?php echo isset($error['berat']) ? $error['berat'] : '';?></div>
</td>
</tr> <tr>
<td width="15%">JUMLAH BARANG</td>
<td width="35%"><div style="color:red;">
<input name="jumlah" id="jumlah" type="text" size="33" value="<?php echo isset($_POST['jumlah']) ? $_POST['jumlah'] : '';?>"/>
<?php echo isset($error['jumlah']) ? $error['jumlah'] : '';?></div>
</td>
</tr>
<tr>
<td width="15%">PEMESANAN</td>
<td width="35%"><div style="color:red;">
<input name="tanggal" id="tanggal" type="text" size="33" value="<?php echo isset($_POST['tanggal']) ? $_POST['tanggal'] : '';?>"/>
<?php echo isset($error['tanggal']) ? $error['tanggal'] : '';?></div>
</td>
</tr>
<tr>
<td width="15%" valign="top">ALAMAT</td>
<td width="35%"><div style="color:red;">
<textarea name="alamat" cols="25" rows="5" id="alamat" type="text" value="<?php echo isset($_POST['alamat']) ? $_POST['alamat'] : '';?>"></textarea>
<?php echo isset($error['alamat']) ? $error['alamat'] : '';?></div>
</td>
</tr>
<tr>
<td width="15%"> </td>
<td width="35%">
<input name="submit" id="submit" type="Submit" value="PESAN" />
<input name="button" id="button" type="button" value="BATAL" onclick=self.history.back()>
</td>
</tr>
</table>
</form>