<?php
//validasi
if($_POST){
$nama=$_POST['nama'];
$t_lahir=$_POST['t_lahir'];
$tgl_lahir=$_POST['tgl_lahir'];
$alamat=$_POST['alamat'];
$kota=$_POST['kota'];
$email=$_POST['email'];
$telp=$_POST['telp'];
$adult=$_POST['adult'];
$children=$_POST['children'];
$telp=$_POST['telp'];
$cek_mail = "^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+))$";
$error=array();
if(empty($nama)){
$error['nama']='NAMA TIDAK BOLEH KOSONG';
}
if(empty($t_lahir)){
$error['t_lahir']='TEMPAT LAHIR TIDAK BOLEH KOSONG';
}
if(empty($alamat)){
$error['alamat']='ALAMAT TIDAK BOLEH KOSONG';
}
if(empty($kota)){
$error['kota']='KOTA TIDAK BOLEH KOSONG';
}
if(empty($email)){
$error['email']='EMAIL TIDAK BOLEH KOSONG';
}
if(empty($telp)){
$error['telp']='TELP TIDAK BOLEH KOSONG';
}
if(empty($adult)){
$error['adult']='ADULT TIDAK BOLEH KOSONG';
}
if(!eregi($cek_mail,($_POST['email']))){
$error['email1']='EMAIL TIDAK VALID!!SILAHKAN MASUKKAN EMAIL YANG VALID';
}
if(empty($error)){
//end validasi
//proses input data
if (isset($_POST['input'])) {
$nama = addslashes (strip_tags ($_POST['nama']));
$t_lahir = addslashes (strip_tags ($_POST['t_lahir']));
$tgllahir = $_POST['tgl']."-".$_POST['bln']."-".$_POST['thn'];
$jk = $_POST['jk'];
$alamat = addslashes (strip_tags ($_POST['alamat']));
$telp = addslashes (strip_tags ($_POST['telp']));
$email = addslashes (strip_tags ($_POST['email']));
$kota = addslashes (strip_tags ($_POST['kota']));
$id_kamar=$_POST['roomid'];
$in= $_POST['tgl1']."-".$_POST['bln1']."-".$_POST['thn1'];
$out= $_POST['tgl2']."-".$_POST['bln2']."-".$_POST['thn2'];
$adult=$_POST['adult'];
$children=$_POST['children'];
$sql1=mysql_query("select * from j_kamar where id_kamar='$id_kamar'");
$row1=mysql_fetch_array($sql1);
$bill=stripslashes($row1['price']);
/*$start = '2012-12-12';
$end = '2012-12-15';*/
$diff = abs(strtotime($in) - strtotime($out));
$day = ceil($diff/(60*60*24)) + 1;
$lama=$day;
$bill=($day * $bill);
/*echo 'Lama Menginap: '.$day.' hari<br/>';*/
/*$sewa = 2000;
echo 'Sewa:'.($day * $bill);*/
//sisa dan booking dikurangi dari tabel j_kamar
$sisa=stripslashes($row1['sisa']);
$booking=stripslashes($row1['booking']);
$h_sisa=$sisa-1;
$h_booking=$booking+1;
//update j_kamar
$updatekamar=mysql_query("update j_kamar set sisa='$h_sisa',booking='$h_booking' where id_kamar='$id_kamar'");
}
//insert ke tabel
$query = "INSERT INTO reservasi VALUES('','$id_kamar','$nama','$t_lahir','$tgllahir','$jk','$alamat','$kota','$email','$telp','$adult','$children','$in','$out','$lama','$bill')";
$sql = mysql_query ($query) or die (mysql_error());
if ($sql) {
echo"<script>alert('Data Berhasil Ditambah')
location.replace('reservasi_hasil.php?id=$id_kamar&nm=$nama')</script>";
} else {
echo"<script>alert('Data Gagal Ditambah')
location.replace('reservasi.php')</script>";
}
}
}
?>
<? include "header.php"; ?>
<!-- header ends -->
<!-- content begins -->
<div class="cont_top"></div>
<div id="content">
<? include "side.php"; ?>
<div id="left">
<h1>Reservasi Kamar Hotel</h1>
<form action="" method="post" enctype="multipart/form-data" name="input" id="form1" >
<table border="2" width="85%">
<tr>
<td colspan="3"><span style="font-size:16px; font-weight:bold;">Informasi Data diri</span></td>
</tr>
<tr>
<td width="40%">Nama<br />
<input type="text" name="nama" value="<? if($error){echo isset($_POST['nama']) ? $_POST['nama'] : '' ; } ?>" />
<div style="color:red"><? echo isset($error['nama']) ? $error['nama'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Jenis Kelamin <br />
<input type="radio" value="L" name="jk"/>Laki-Laki <input type="radio" value="P" name="jk" />Perempuan</td><td></td>
</tr>
<tr>
<td>Tempat Lahir<br />
<input type="text" name="t_lahir" value="<? if($error){echo isset($_POST['t_lahir']) ? $_POST['t_lahir'] : '' ; } ?>" />
<div style="color:red"><? echo isset($error['t_lahir']) ? $error['t_lahir'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Tgl Lahir<br />
<select name="tgl">
<?php
for ($i=1; $i<=31; $i++) {
$tg = ($i<10) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select>
-
<select name="bln">
<?php
for ($i=1; $i<=12; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select>
-
<select name="thn" >
<?php
for ($i=1970; $i<=2000; $i++) {
echo "<option value='$i'>$i</option>";
}
?>
</select></td>
<td></td>
</tr>
<tr height="20">
<td colspan="3"><span style="font-size:16px; font-weight:bold;">Your Contac</span></td>
</tr>
</tr>
<tr>
<td>Alamat<br />
<input type="text" name="alamat" value="<? if($error){echo isset($_POST['alamat']) ? $_POST['alamat'] : '' ; } ?>" />
<div style="color:red"><? echo isset($error['alamat']) ? $error['alamat'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Kota<br />
<input type="text" name="kota" value="<? if($error){echo isset($_POST['kota']) ? $_POST['kota'] : '' ; } ?>" />
<div style="color:red"><? echo isset($error['kota']) ? $error['kota'] :''; ?></div> </td>
<td></td>
</tr>
<tr>
<td>Email<br />
<input type="text" name="email" <? if($error){echo isset($_POST['email']) ? $_POST['email'] : '' ; } ?> />
<div style="color:red"><? echo isset($error['email']) ? $error['email'] :''; ?><? echo isset($error['email1']) ? $error['email1'] : '' ; ?></div> </td>
<td width="30"></td>
</tr>
<tr>
<td>Telp<br />
<input type="text" name="telp" <? if($error){echo isset($_POST['telp']) ? $_POST['telp'] : '' ; } ?> />
<div style="color:red"><? echo isset($error['telp']) ? $error['telp'] :''; ?></div> </td>
<td></td>
</tr>
<tr>
<td colspan="3"><span style="font-size:16px; font-weight:bold;">Your Reservation</span></td>
</tr>
<td>Room Type<br />
<select name="roomid" id="roomid" >
<option value="" >Select Room</option>
<? $sql=mysql_query("select * from j_kamar ");
while($row=mysql_fetch_array($sql)){
echo "<option value='$row[id_kamar]'>$row[nama]</option>";
} ?>
</select></td>
<td><? /*if($row1['sisa']==0) {
echo "Maaf kamar sedng kosong";
}*/ ?></td>
<? /*$no=1;
$sql=mysql_query("select * from j_kamar");
while($row=mysql_fetch_array($sql) {
$jenis=stripslashes($row['jenis'])*/;
?>
<tr>
<td>Adult<br />
<input type="text" name="adult" value="<? if($error){echo isset($_POST['adult']) ? $_POST['adult'] : '' ; } ?>"/>
<div style="color:red"><? echo isset($error['adult']) ? $error['adult'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Children<br />
<input type="text" name="children" /> </td>
<td></td>
</tr>
<tr>
<td>Check In<br />
<select name="tgl1">
<?php
for ($i=1; $i<=31; $i++) {
$tg = ($i<10) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select>
-
<select name="bln1">
<?php
for ($i=1; $i<=12; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select>
-
<select name="thn1">
<option value="<?php echo date("Y"); ?>" selected="selected"><?php echo date("Y"); ?></option>
</select> </td>
<td colspan="2"></td>
<td>Check Out<br />
<select name="tgl2">
<?php
for ($i=1; $i<=31; $i++) {
$tg = ($i<10) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select>
-
<select name="bln2">
<?php
for ($i=1; $i<=12; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select>
-
<select name="thn2">
<option value="<?php echo date("Y"); ?>" selected="selected"><?php echo date("Y"); ?></option>
</select></td>
<td></td>
</tr>
<tr>
<td height="40" align="right" style="vertical-align:bottom"><input type="submit" name="input" value="Send" /> <input type="reset" value="Reset" /></td>
</tr>
</table>
</form>
<?php
//jangan lupa konek ke database
$idKamar = $_GET['id'];
$hs = mysql_query("select * from j_kamar where id_kamar='".$idKamar."'");
$data = mysql_fetch_assoc($hs);
header("Content-Type: text/json");
echo json_encode($data);
kemudian di file reservasi.php tambahkan javascript berikut:<script type="text/javascript" src="jquery.js"></script> <!-- tambahkan script jquery, sesuaikan dengan lokasi di websitemu -->
<script type="text/javascript">
$(document).ready(function(){
$('#roomid').change(function(){
var idkamar = $(this).val();
$.ajax({
url:'cek_kamar.php?id='+idkamar,
dataType:'json',
success:function(hasil){
var sisa = parseFloat(hasil.sisa);
if(sisa <= 0){
alert('Anda tidak bisa booking kamar ini');
$(':submit').attr('disabled','disabled');
}else{
$(':submit').removeAttr('disabled');
}
}
});
});
});
</script>
<? include "cek_kamar.php"; ?>
<script type="text/javascript" src="lib/jquery.1.4.2.js"></script>
<script type="text/javascript" src="lib/jquery.custom.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#roomid').change(function(){
var idkamar = $(this).val();
$.ajax({
url:'cek_kamar.php?id='+idkamar,
dataType:'json',
success:function(hasil){
var sisa = parseFloat(hasil.sisa);
if(sisa <= 0){
alert('Anda tidak bisa booking kamar ini');
$(':submit').attr('disabled','disabled');
}else{
$(':submit').removeAttr('disabled');
}
}
});
});
});
</script>
<? include "konek.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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Grand Zuri</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<!-- Begin JavaScript -->
<script type="text/javascript" src="lib/jquery.1.4.2.js"></script>
<script type="text/javascript" src="lib/jquery.custom.js"></script>
<script type="text/javascript" src="lib/jquery-1.8.1.js"></script> <!-- tambahkan script jquery, sesuaikan dengan lokasi di websitemu -->
<script type="text/javascript">
$(document).ready(function(){
$('#roomid').change(function(){
var idkamar = $(this).val();
$.ajax({
url:'cek_kamar.php?id='+idkamar,
dataType:'json',
success:function(hasil){
var sisa = parseFloat(hasil.sisa);
if(sisa <= 0){
alert('Anda tidak bisa booking kamar ini');
$(':submit').attr('disabled','disabled');
}else{
$(':submit').removeAttr('disabled');
}
}
});
});
});
</script>
<? include "konek.php"; ?>
<style type="text/css">
body {
background-color: #FFFFFF;
}
</style>
</head>
<body>
<?php
//validasi
if($_POST){
$nama=$_POST['nama'];
$t_lahir=$_POST['t_lahir'];
$tgl_lahir=$_POST['tgl_lahir'];
$alamat=$_POST['alamat'];
$kota=$_POST['kota'];
$email=$_POST['email'];
$telp=$_POST['telp'];
$adult=$_POST['adult'];
$children=$_POST['children'];
$telp=$_POST['telp'];
$cek_mail = "^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+))$";
$error=array();
if(empty($nama)){
$error['nama']='NAMA TIDAK BOLEH KOSONG';
}
if(empty($t_lahir)){
$error['t_lahir']='TEMPAT LAHIR TIDAK BOLEH KOSONG';
}
if(empty($alamat)){
$error['alamat']='ALAMAT TIDAK BOLEH KOSONG';
}
if(empty($kota)){
$error['kota']='KOTA TIDAK BOLEH KOSONG';
}
if(empty($email)){
$error['email']='EMAIL TIDAK BOLEH KOSONG';
}
if(empty($telp)){
$error['telp']='TELP TIDAK BOLEH KOSONG';
}
if(empty($adult)){
$error['adult']='ADULT TIDAK BOLEH KOSONG';
}
if(!eregi($cek_mail,($_POST['email']))){
$error['email1']='EMAIL TIDAK VALID!!SILAHKAN MASUKKAN EMAIL YANG VALID';
}
if(empty($error)){
//end validasi
//proses input data
if (isset($_POST['input'])) {
$nama = addslashes (strip_tags ($_POST['nama']));
$t_lahir = addslashes (strip_tags ($_POST['t_lahir']));
$tgllahir = $_POST['tgl']."-".$_POST['bln']."-".$_POST['thn'];
$jk = $_POST['jk'];
$alamat = addslashes (strip_tags ($_POST['alamat']));
$telp = addslashes (strip_tags ($_POST['telp']));
$email = addslashes (strip_tags ($_POST['email']));
$kota = addslashes (strip_tags ($_POST['kota']));
$id_kamar=$_POST['roomid'];
$adult=$_POST['adult'];
$children=$_POST['children'];
$sql1=mysql_query("select * from j_kamar where id_kamar='$id_kamar'");
$row1=mysql_fetch_array($sql1);
$bill=stripslashes($row1['price']);
$in= $_POST['tgl1']."-".$_POST['bln1']."-".$_POST['thn1'];
$out= $_POST['tgl2']."-".$_POST['bln2']."-".$_POST['thn2'];
if(strtotime($in) > strtotime($out)){
echo"<script>alert('Tanggal Yang Anda Masukkan Invalid<br>Silahkan coba Lagi')
location.replace('reservasi.php')</script>";
} else {
$diff = abs(strtotime($in) - strtotime($out));
$day = ceil($diff/(60*60*24)) + 1;
$lama=$day;
$bill=($day * $bill);
$sisa=stripslashes($row1['sisa']);
$booking=stripslashes($row1['booking']);
$h_sisa=$sisa-1;
$h_booking=$booking+1;
$updatekamar=mysql_query("update j_kamar set sisa='$h_sisa',booking='$h_booking' where id_kamar='$id_kamar'");
//insert ke tabel
$query = "INSERT INTO reservasi VALUES('','$id_kamar','$nama','$t_lahir','$tgllahir','$jk','$alamat','$kota','$email','$telp','$adult','$children','$in','$out','$lama','$bill')";
$sql = mysql_query ($query) or die (mysql_error());
if ($sql) {
echo"<script>alert('Data Berhasil Ditambah')
location.replace('reservasi_hasil.php?id=$id_kamar&nm=$nama')</script>";
} else {
echo"<script>alert('Data Gagal Ditambah')
location.replace('reservasi.php')</script>";
}
}
}
}
}
?>
<div id="bg_img">
<div id="main">
<div id="main_img">
<!-- header begins -->
<? include "header.php"; ?>
<!-- header ends -->
<!-- content begins -->
<div class="cont_top"></div>
<div id="content">
<? include "side.php"; ?>
<div id="left">
<h1>Reservasi Kamar Hotel</h1>
<form action="" method="post" enctype="multipart/form-data" name="input" id="form1" >
<table border="2" width="85%">
<tr>
<td colspan="3"><span style="font-size:16px; font-weight:bold;">Informasi Data diri</span></td>
</tr>
<tr>
<td width="40%">Nama<br />
<input type="text" name="nama" value="<? if($error){echo isset($_POST['nama']) ? $_POST['nama'] : '' ; } ?>" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;" />
<div style="color:red"><? echo isset($error['nama']) ? $error['nama'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Jenis Kelamin <br />
<input type="radio" value="L" name="jk"/>Laki-Laki <input type="radio" value="P" name="jk" />Perempuan</td><td></td>
</tr>
<tr>
<td>Tempat Lahir<br />
<input type="text" name="t_lahir" value="<? if($error){echo isset($_POST['t_lahir']) ? $_POST['t_lahir'] : '' ; } ?>" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;" />
<div style="color:red"><? echo isset($error['t_lahir']) ? $error['t_lahir'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Tgl Lahir<br />
<select name="tgl" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<?php
for ($i=1; $i<=31; $i++) {
$tg = ($i<10) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select>
-
<select name="bln" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<?php
for ($i=1; $i<=12; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select>
-
<select name="thn" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;" >
<?php
for ($i=1970; $i<=2000; $i++) {
echo "<option value='$i'>$i</option>";
}
?>
</select></td>
<td></td>
</tr>
<tr height="30"><td></td></tr>
<tr height="30">
<td colspan="3"><span style="font-size:16px; font-weight:bold;">Your Contac</span></td>
</tr>
</tr>
<tr>
<td>Alamat<br />
<input type="text" name="alamat" value="<? if($error){echo isset($_POST['alamat']) ? $_POST['alamat'] : '' ; } ?>" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;" />
<div style="color:red"><? echo isset($error['alamat']) ? $error['alamat'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Kota<br />
<input type="text" name="kota" value="<? if($error){echo isset($_POST['kota']) ? $_POST['kota'] : '' ; } ?>" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;"/>
<div style="color:red"><? echo isset($error['kota']) ? $error['kota'] :''; ?></div> </td>
<td></td>
</tr>
<tr>
<td>Email<br />
<input type="text" name="email" <? if($error){echo isset($_POST['email']) ? $_POST['email'] : '' ; } ?> style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;" />
<div style="color:red"><? echo isset($error['email']) ? $error['email'] :''; ?><? echo isset($error['email1']) ? $error['email1'] : '' ; ?></div> </td>
<td width="30"></td>
</tr>
<tr>
<td>Telp<br />
<input type="text" name="telp" <? if($error){echo isset($_POST['telp']) ? $_POST['telp'] : '' ; } ?> style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;" />
<div style="color:red"><? echo isset($error['telp']) ? $error['telp'] :''; ?></div> </td>
<td></td>
</tr>
<tr height="30"><td></td></tr>
<tr>
<td colspan="3"><span style="font-size:16px; font-weight:bold;">Your Reservation</span></td>
</tr>
<td>Room Type<br />
<select name="roomid" id="roomid" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<option value="" >Select Room</option>
<? $sql=mysql_query("select * from j_kamar ");
while($row=mysql_fetch_array($sql)){
echo "<option value='$row[id_kamar]'>$row[nama]</option>";
} ?>
</select></td>
<td></td>
<tr>
<td>Adult<br />
<input type="text" name="adult" value="<? if($error){echo isset($_POST['adult']) ? $_POST['adult'] : '' ; } ?>" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;"/>
<div style="color:red"><? echo isset($error['adult']) ? $error['adult'] :''; ?></div> </td>
<td colspan="2"></td>
<td>Children<br />
<input type="text" name="children" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;"/> </td>
<td></td>
</tr>
<tr>
<td>Check In<br />
<select name="tgl1" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<?php
for ($i=1; $i<=31; $i++) {
$tg = ($i<10) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select>
-
<select name="bln1" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<?php
for ($i=1; $i<=12; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select>
-
<select name="thn1" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<option value="<?php echo date("Y"); ?>" selected="selected"><?php echo date("Y"); ?></option>
</select> </td>
<td colspan="2"></td>
<td>Check Out<br />
<select name="tgl2" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<?php
for ($i=1; $i<=31; $i++) {
$tg = ($i<10) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select>
-
<select name="bln2" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<?php
for ($i=1; $i<=12; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select>
-
<select name="thn2" style="background:#FF9933; color: #000000; border: 2px ridge #7F4500;">
<option value="<?php echo date("Y"); ?>" selected="selected"><?php echo date("Y"); ?></option>
</select></td>
<td></td>
</tr>
<tr>
<td height="40" align="right" style="vertical-align:bottom"><input type="submit" name="input" value="Send" /> <input type="reset" value="Reset" /></td>
</tr>
</table>
</form>
<div style=" height:10px"></div>
</div>
<div style="clear: both; height: 10px"></div>
</div>
<div class="cont_bot"></div>
<!-- content ends -->
<div style="height:10px;"></div>
<? include "footer.php"; ?>
</div>
</div>
</div>
</body>
</html>
Dan ini cek_kamar.php<?php
//jangan lupa konek ke database
$konek=mysql_connect ("localhost","root","") or die ("koneksi gagal");
mysql_select_db("hotel2");
$idKamar = $_GET['id'];
$hs = mysql_query("select * from j_kamar where id_kamar='".$idKamar."'");
$data = mysql_fetch_assoc($hs);
header("Content-Type: text/json");
echo json_encode($data);
?>
Maaf Mas sedikit menyusahkan..<script type="text/javascript">
$(document).ready(function(){
$('#roomid').change(function(){
var idkamar = $(this).val();
$.ajax({
url:'cek_kamar.php?id='+idkamar,
dataType:'json',
success:function(hasil){
var sisa = parseFloat(hasil.sisa);
if(sisa <= 0){
alert('Anda tidak bisa booking kamar ini');
$(':submit').attr('disabled','disabled');
}else{
$(':submit').removeAttr('disabled');
}
}
});
});
});
menjadi<script type="text/javascript">
$(document).ready(function(){
$('#roomid').change(function(){
var idkamar = $(this).val();
$.ajax({
url:'cek_kamar.php?id='+idkamar,
dataType:'json',
success:function(hasil){
var sisa = parseFloat(hasil.sisa);
if(sisa <= 0){
alert('Anda tidak bisa booking kamar ini');
$(':submit').attr('disabled','disabled');
}else{
$(':submit').removeAttr('disabled');
}
},
error:function(){
alert('terjadi error, silahkan coba lagi');
}
});
});
});
-- phpMyAdmin SQL Dump
-- version 2.8.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 18, 2012 at 12:20 AM
-- Server version: 5.0.21
-- PHP Version: 5.1.4
--
-- Database: `hotel2`
--
-- --------------------------------------------------------
--
-- Table structure for table `j_kamar`
--
CREATE TABLE `j_kamar` (
`id_kamar` int(11) NOT NULL auto_increment,
`nama` varchar(50) collate latin1_general_ci NOT NULL,
`all` int(11) NOT NULL,
`booking` int(11) NOT NULL,
`sisa` int(11) NOT NULL,
`price` int(20) NOT NULL,
PRIMARY KEY (`id_kamar`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=9 ;
--
-- Dumping data for table `j_kamar`
--
INSERT INTO `j_kamar` VALUES (1, 'Standard', 26, 0, 26, 440000);
INSERT INTO `j_kamar` VALUES (2, 'Superior', 39, 4, 35, 560000);
INSERT INTO `j_kamar` VALUES (3, 'Deluxe', 15, 16, -1, 660000);
INSERT INTO `j_kamar` VALUES (4, 'Resort Pool View', 20, 0, 20, 750000);
INSERT INTO `j_kamar` VALUES (5, 'Junior Suite', 8, 2, 6, 850000);
INSERT INTO `j_kamar` VALUES (6, 'Executive Suite', 1, 0, 1, 950000);
INSERT INTO `j_kamar` VALUES (7, 'Villa 1', 1, 2, -1, 1100000);
INSERT INTO `j_kamar` VALUES (8, 'Villa 2', 1, 0, 1, 1600000);
-- --------------------------------------------------------
--
-- Table structure for table `reservasi`
--
CREATE TABLE `reservasi` (
`id` int(11) NOT NULL auto_increment,
`id_kamar` int(11) NOT NULL,
`nama` varchar(30) collate latin1_general_ci NOT NULL,
`t_lahir` varchar(30) collate latin1_general_ci NOT NULL,
`tgl_lahir` varchar(30) collate latin1_general_ci NOT NULL,
`jk` enum('L','P') collate latin1_general_ci NOT NULL,
`alamat` varchar(50) collate latin1_general_ci NOT NULL,
`kota` varchar(30) collate latin1_general_ci NOT NULL,
`email` varchar(30) collate latin1_general_ci NOT NULL,
`telp` varchar(30) collate latin1_general_ci NOT NULL,
`adult` int(11) NOT NULL,
`children` int(11) NOT NULL,
`check_in` varchar(30) collate latin1_general_ci NOT NULL,
`check_out` varchar(30) collate latin1_general_ci NOT NULL,
`lama` int(11) NOT NULL,
`bill` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=25 ;
--
-- Dumping data for table `reservasi`
--
INSERT INTO `reservasi` VALUES (5, 2, 'Anggun S', 'Pekan Baru', '19-09-1991', 'P', 'Jl.Beringin', 'Duri', 'Anggun@gmail.com', '(0765) 1155', 1, 2, '19-09-2012', '20-09-2012', 2, 1120000);
INSERT INTO `reservasi` VALUES (4, 2, 'Bangkit', 'Pekan Baru', '20-02-1982', 'L', 'Jl.Beringin', 'Duri', 'bangkit@localhost', '11', 1, 1, '04-10-2012', '09-10-2012', 6, 3360000);
INSERT INTO `reservasi` VALUES (6, 2, 'Ade', 'Duri', '16-06-1986', 'L', 'Jl.Sudirman', 'xxs', 'ade@ymail.com', '(0765) 1155', 3, 2, '10-10-2012', '10-10-2012', 1, 560000);
INSERT INTO `reservasi` VALUES (7, 2, 'setya td', 'Duri', '10-10-1970', 'L', 'Jl.Beringin', 'Dumai', 'setia@gmail.com', '11', 2, 2, '09-11-2012', '10-11-2012', 2, 1120000);
INSERT INTO `reservasi` VALUES (23, 3, 'welni', 'duri', '01-01-1970', 'P', 'jl.makmur', 'duri', 'welni@gmail.com', '345677', 2, 2, '01-01-2012', '02-01-2012', 2, 1320000);
INSERT INTO `reservasi` VALUES (24, 7, 'dadang', 'pekanbaru', '01-01-1970', 'L', 'jl.makmur', 'duri', 'dadang@gmail.com', '345677', 3, 2, '01-01-2012', '02-01-2012', 2, 2200000);
Terima Kasih Ellyx Christian..