Advertisement
Doctor0L

kamar-input.php

Apr 16th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.37 KB | None | 0 0
  1. <?php
  2. require ('library/config.php');
  3. //Autonumber ID
  4. $a = 'KMR/01/0';
  5. $pilih = mysql_query("SELECT MAX(id_kamar) AS MaxID FROM ap_kamar WHERE id_kamar LIKE '$a%'");
  6. $data = mysql_fetch_array($pilih);
  7. $b = substr($data['MaxID'],8,2);
  8. $c = (int)$b;
  9. $d = $c + 1;
  10. //Insert ke database
  11. if(isset($_POST['submit'])){
  12.     $id = $_POST['txtID'];
  13.     $type = $_POST['txtType'];
  14.     $status = $_POST['txtStatus'];
  15.     $query = "INSERT INTO `app`.`ap_kamar`(`id_kamar` ,`status_kamar` ,`id_fasilitas`) VALUES('$id','$status','$type')";
  16.     if(mysql_query($query)){
  17.         $m = '';
  18.         $m = 'display:none;';
  19.     }else{
  20.         echo "<script>alert('gagal');</script>";
  21.         $m = 'display:none;';
  22.         $m = '';
  23.     }
  24. }else{
  25. $m = "display:none;";
  26. $n = "display:none;";
  27. }
  28. ;?>
  29.  
  30.  <div class="row">
  31.           <div class="col-lg-12">
  32.             <h1>Data Kamar <small>Add Room</small></h1>
  33.             <ol class="breadcrumb">
  34.               <li class="active"><i class="fa fa-dashboard"></i> <a href="?page=kamar">Kamar</a></li>
  35.               <li>Tambah Kamar</li>
  36.             </ol>
  37.             <div class='alert alert-success alert-dismissable' style="<?php echo $m ;?>">
  38.               <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
  39.               <b>Penambahan data berhasil !</b> <a class='alert-link' href='?page=kamar-view&id=$id'><i>Lihat Hasil<i></a> .
  40.               <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
  41.               <b>Penambahan data gagal !</b> Pastikan data yang dimasukan benar ! .
  42.             </div>
  43.             <div class='alert alert-danger alert-dismissable' style="<?php echo $n ;?>" >
  44.             </div>
  45.             <div class="panel-body">
  46.                 <div class="table-responsive">
  47.            
  48.             <form action="<?php $_SERVER['PHP_SELF'];?>" method="POST" >
  49.             <table class="table table-bordered table-hover table-striped " >
  50.                 <tr>
  51.                     <th colspan="3" ><h2 >Tambah Kamar</h2></th>
  52.                 <tr>
  53.                 <tr>
  54.                     <td>ID-Kamar</td>
  55.                     <td align="center">:</td>
  56.                     <td><input type="text" value="<?php echo $a.sprintf('%02s',$d) ; ?>" name="txtID" id="txtID" size="30" maxlength="30" required/></td>
  57.                 </tr>
  58.                 <tr>
  59.                     <td>Type Kamar</td>
  60.                     <td align="center">:</td>
  61.                     <td>
  62.                     <select name="txtType" required>
  63.                     <option><--Pilih Option--></option>
  64.                     <?php
  65.                         $fasi = mysql_query("SELECT * FROM ap_fasilitas ");
  66.                         while($list=mysql_fetch_assoc($fasi)){
  67.                     ?>
  68.                     <option value="<?php echo $list['id_fasilitas'];?>"><?php echo $list['type'];?></option>
  69.                     <?php } ?>
  70.                     </select>
  71.                     </td>
  72.                 </tr>
  73.                 <tr>
  74.                     <td>Status Kamar</td>
  75.                     <td align="center">:</td>
  76.                     <td>
  77.                     <p>
  78.                         <label>
  79.                             <input name="txtStatus" type="radio" id="RadioGroup" value="1" checked="checked" />
  80.                         Available</label>
  81.                         <br />
  82.                         <label>
  83.                             <input type="radio" name="txtStatus" value="0" id="RadioGroup" />
  84.                         Not Available</label>
  85.                         <br />
  86.                     </p>
  87.                     </td>
  88.                 </tr>
  89.                 <tr>
  90.                     <td>&nbsp;</td>
  91.                     <td>&nbsp;</td>
  92.                     <td><input type="submit" class="button" value="SUBMIT"/>&nbsp;<input type="reset" class="button" value="RESET"/>&nbsp;<input type="button" value="KEMBALI" class="button" onClick="self.history.back()"></td>
  93.                 </tr>
  94.             </table>
  95.             </form><!--End Form-->
  96.                 </div>
  97.             </div><!--End Responsive Table-->
  98.            
  99.           </div>
  100.         </div><!-- /.row -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement