HOTEL RESERVATION SYSTEM

Database Management System Project

Contents

1. 2. 3. 4. 5.

Introduction Requirements Design Coding Output

…………………………………………. …………………………………………. …………………………………………. …………………………………………. ………………………………………….

1 2 3 7 20

they are provided with food and other services. These records help in generating bill. To make their stay comfortable.1. Introduction Hotel needs to maintain the record of guests and reserve rooms beforehand. 1 . Customers should be able to know the availability of the rooms on a particular date. The record of the food taken by each customer and the services availed by the customer should be kept. They should be able to reserve the available rooms according to their need in advance.

Guests should be able to book the available rooms online. 4. The system should be able to keep the records of the guests and the room allotted to them. Requirements The hotel reservation system should be able to satisfy the following requirements : 1.2. The system should be able to generate the bill for a customer. 2 . 3. Customers should be able to know the availability of the rooms on a particular date. 5. 2. The record of food and services availed by the customer should be kept.

It has a weak entity MEMBERS. FamilyHeadSSN. 3. GUEST PAYS BILL. 3 . GUEST may USES FACILITIES. Type and Status(vacant or occupied) 5. MEMBERS have attributes Name(Weak key)and age. Date and Time. One Guest(Family or Company) can be alloted more than one room. GUEST are ALLOTED ROOM from CheckInDate to CheckOutDate. FACILITIES has attributes FacilityId(Key). GUEST can be of two types FAMILY and COMPANY 2. 4. BILL has attributes BillNo(Key). NoOfAdults. Designation. GUEST ORDERS FOOD at some Time on some Date. Rate and Type.3. Address. One GUEST can use more than one FACILITIES. Relations and their description 1. Children. FOOD has attributes ProductId(Key). Rate. ROOM has attributes RoomNo(Key). Design Entities And Attributes 1. It has a weak entity MEMBERS having attributes Name(Weak Key). GUEST can order more than one FOOD item and one FOOD item can be ordered by one GUEST. 6. COMPANY has attributes Name and Location. 4. 7. A GUEST must pay a BILL. 3. 2. Type and Rate. FAMILY has attributes FamilyHeadName. Age.

Figure 1: Hotel Reservation Database Schema 4 .

Schema diagram for the Hotel Reservation Database schema FAMILY Family_Head_SSN Family_Head_Name Address Phone_No No_Of_Adults No_Of_Children FAMILY MEMBERS Family_Head_SSN Name Age COMPANY Name Location COMPANY MEMBERS CName Name Age Designation GUEST Guest_ID ROOM Room_No Type Rate Status Guest_ID Check_In_Date Check_Out_Date 5 .Fig 2.

3. There is no transitive dependency at all . we can conclude that tables are in BCNF. 2. In all Tables attribute values are atomic hence they are in 1NF. According to the figure: 1. 4. 6 .FACILITIES Facility_ID Rate Type Guest_ID BILL Bill_No Amount Date Paying_Method Guest_ID FOOD Product_ID Rate Type ORDERS Guest_ID Product_ID Date Time Quantity The Functional Dependencies are shown in the figure. so they are in 3NF. All tables are also in BCNF because left hand side of all FDs contain only primary key (which is of course superkey) corresponding to their respective relation. So. In all tables there is no partial dependency and hence they are in 2NF.

$outmon = $_POST['D5']. } $inyear = $_POST['D3']. $inday = $_POST['D1']. $check1 = check($outyear.$outmon. $outday = $_POST['D4']."-".$outday. $inmon = $_POST['D2'].$outmon. header("Location: Areservation. ""). $indate = $inyear. $roomresult = mysql_query($roomsql. echo "$outyear $inyear".$inday. } if($noofrooms > $no) { header("Location: notavailable.$conn) or die(mysql_error())."-". echo "$check1". } for($j = 0. $outyear = $_POST['D6'].$inday)."-".$conn). if($check1!=1 || $noofrooms == 0) { echo "check out date smaller than check in date". $count = 0. $no=0.$inmon. $noofrooms = $_POST['T1']. } $roomsql = "select * from room where type = '$utype'". Check Availability: <?php $conn = mysql_connect("localhost". while($rooms = mysql_fetch_array($roomresult)) { $roomnos[$no] = $rooms['r_no'].$outday."-". } 7 . $temresult = mysql_query($temsql. if($temresult) { $deltempsql = "drop table temp". $db = mysql_select_db("hotel".4. $outdate = $outyear.html").$conn). $no++.$conn). Coding 1. $deltempresult = mysql_query($deltempsql.$inyear. $j< $no. "root". $j++) { echo "<br> $roomnos[$j] ". $utype = $_POST['D7'].$inmon. $temsql = "select * from temp".html"). $flag = 0.

} 8 .month(out_date) as omonth. $aomonth = $allot['omonth'].$allotedsql = "select room_no. of availability but satisfies in later record //Deletes those room nos. } for($j = 0. } } } echo $no. $result2 = check($inyear.month(in_date) as imonth. $conn) or die(mysql_error()). $j< $no. for($i=0.$aoyear. which do not satisfy condition of availability in later record $cannotbealloted = $allot['room_no']. $aoyear = $allot['oyear']. while($allot = mysql_fetch_array($allotedresult)) { echo " in while allot ". for($j=$i.$outyear..$aoday). //delete those room nos. if($result1==1 || $result2 == 1) { } else { echo " in else loop". } $i = $no.$inday. $i++) { if($cannotbealloted == $roomnos[$i]) { echo " room no = $cannotbealloted ".year(in_date) as iyear.$aimonth. $j< $no. $aoday = $allot['oday'].$aiday.$outmon.. } $no--.$aomonth. $j++) { echo "<br> $roomnos[$j]".dayofmonth(in_date) as iday. for($j = 0. which at first don't satisfy condn. $j++) { $roomnos[$j] = $roomnos[$j+1]. $j++) { echo "<br> $roomnos[$j] ". $aiyear = $allot['iyear'].$inmon. $allotedresult = mysql_query($allotedsql. $outday).year(out_date) as oyear from alloted order by room_no". $result1 = check($aiyear.dayofmonth(out_date) as oday. $i<$no. $aimonth = $allot['imonth']. $j < $no. $aiday = $allot['iday']. $noofalloted = mysql_num_rows($allotedresult). echo " first check $result1 second check $result2 <br>".

$i++) { $flag = createinsert($roomnos[$i]. "root". return $flag. } } } //checks which of two dates is bigger function check($year2. $conn)) { // echo "record inserted". in_date date. if($flag==0) { $csql = "create table temp (room_no int(3). // echo "$roomno $indate $outdate".$indate.$year1. } if($flag == 1) { header("Location: Areservation2. $conn = mysql_connect("localhost". $result = mysql_query($csql.$outdate. if($result == 1) { $flag = 1.$day2. $db = mysql_select_db("hotel".$month2. if(mysql_query($isql.'$outdate')". } } if($flag == 1) { $isql = "insert into temp values('$roomno'. } else { header("Location: notavailable.out_date date check(out_date > in_date))".$conn).$day1) { if($year2 > $year1) { return 1. $i < $noofrooms .html").$conn).html"). $flag).if($noofrooms <= $no) { for($i=0. } } function createinsert($roomno. } 9 .$flag) { // echo "\n entered in createinsert function". } else { // echo "record not inserted".$indate.$month1. "").'$indate'.$outdate.

} } } } ?> 10 .else { if($year2 == $year1 && $month2 > $month1) { return 1. } else { if($year2 == $year1 && $month2 == $month1 && $day2 > $day1) { return 1. } else { //in date is bigger return 0.

'$name'. "root".$advance)". $noofadult. } else { exit. if($noofadult == 0 || $name == ""|| $address == "" || $advance == 0) { header("Location: Areservation2. $db = mysql_select_db("hotel". Making Reservation: <?php $conn = mysql_connect("localhost". $advance = $_POST['T6'].$conn)) { $flag = 1. $phno = $_POST['T2']. $cardno = $_POST['T3']. $name = $_POST['T1']. $outdate = $temp1['out_date']. $conn) or die(mysql_error()). $address = $_POST['S1']. while($temp1 = mysql_fetch_array($tempresult)) { $roomno = $temp1['room_no'].$phno. } else { echo "something went wrong". $conn)) { echo "record added!". } $sql = "INSERT INTO guest values (''. } $tempsql = "select * from temp". if (mysql_query($insertsql. $tempresult = mysql_query($tempsql. $flag = 0. $noofchild = $_POST['T5']. $indate = $temp1['in_date']. $roomno. } $guestsql = "select max(id) as g_id from guest".$cardno. while ($guest = mysql_fetch_array($guestresult)) { $g_id = $guest['g_id'].'$indate'.html").'$address'. } } if($flag == 2) { 11 . $flag = 2.$conn). $noofadult = $_POST['T4']. $insertsql = "insert into alloted values($g_id. $guestresult = mysql_query($guestsql.'$outdate')".$noofchild. $conn) or die(mysql_error()). ""). if(mysql_query($sql.2.

} ?> 12 . $dropsql = "drop table temp".html").$conn)) { $flag = 3. } else { echo "something went sdf wrong". // header("Location: reservation2.echo "table drop if statement". } } if ($flag == 3) { // echo "record added!". if(mysql_query($dropsql.php"). header("Location: Areserved.

&nbsp. "root". <a 13 . $db = mysql_select_db("hotel".</a>&nbsp. } --> </style> </head> <?php $conn = mysql_connect("localhost".gif" alt="" width="15" height="1" border="0" /></td> <td height="62" colspan="3" class="logo" nowrap="nowrap">HOTEL LANDMARK </td> <td width="40">&nbsp. "").html">FOOD</a>&nbsp.&nbsp.Home Page</title> <meta http-equiv="Content-Type" content="text/html.html">HOME</a>&nbsp.php" method="post"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15" nowrap="nowrap"><img src="mm_spacer.&nbsp.Copyright 2005 Macromedia. $guestsql = "select max(id) as g_id from guest". charset=iso-8859-1" /> <link rel="stylesheet" href="mm_lodging1.&nbsp.dtd"> <html xmlns="http://www.org/TR/xhtml1/DTD/xhtml1-transitional. $guestresult = mysql_query($guestsql.css" type="text/css" /> <style type="text/css"> <!-.0 Transitional//EN" "http://www. All rights reserved. Inc.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#a4c2c2"> <td width="15" nowrap="nowrap">&nbsp.w3. while ($guest = mysql_fetch_array($guestresult)) { $g_id = $guest['g_id'].&nbsp.w3.</td> <td width="100%">&nbsp. --> <title>Lodging . } ?> <body bgcolor="#999966"> <form action="Areservation2. $conn) or die(mysql_error()).</td> <td height="36" colspan="3" id="navigation" class="navText"><a href="administrator.&nbsp. Reserved Status: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1. font-weight: bold.$conn).3.org/1999/xhtml"> <!-.</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"><img src="mm_spacer.style1 { font-size: 12px. <a href="Afoodorder.&nbsp.DW6 --> <head> <!-.

</p> <p class="style1">Your Guest ID is <?php echo "$g_id"?></p></td> <td width="40" height="276">&nbsp. Allahabad <br /> </td> <td width="15">&nbsp.</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"><img src="mm_spacer.html"> SERVICES</a>&nbsp.</td> <td width="40">&nbsp.&nbsp.gif" alt="" width="50" height="1" border="0" /></b></td> <td width="440" valign="top" height="276">&nbsp.</td> <td width="100%">&nbsp.&nbsp.&nbsp.</p> <p class="style1">Room has been registered.&nbsp. <p>&nbsp.</td> <td width="100%" height="276">&nbsp.html">BILL</a>&nbsp.&nbsp.&nbsp.&nbsp.</td> <td width="200" class="sidebarText" id="padding">Hotel LandMark.&nbsp.&nbsp.&nbsp.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr> <td width="15" height="164"></td> <td width="215" height="164"></td> <td width="50" height="164"></td> <td width="440" height="164"></td> <td width="40" height="164"></td> <td width="100%" height="164"></td> </tr> </table> </form> </body> </html> 14 .&nbsp.&nbsp.</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6" height="1"><img src="mm_spacer.&nbsp.&nbsp.&nbsp.&nbsp.&nbsp. <a href="Abill.&nb sp.&nbsp.&nbsp.&nbsp.&nbs p.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#ffffff"> <td width="230" colspan="2" valign="top" bgcolor="#a4c2c2" height="276"> <img src="pic5.jpg" alt="Home Page Image" width="210" height="210" border="0" lowsrc="pic5.&nbsp.&nbsp.&nbsp.jpg" /> <table border="0" cellspacing="0" cellpadding="0" width="230"> <tr> <td width="15">&nbsp.&nbsp.&nbsp.href="Aservices.&nbsp.</td> </tr> </table> </td> <td width="50" valign="top" height="276"><b><img src="mm_spacer.

$db = mysql_select_db("hotel".$_POST['T18']). entry($_POST['T9']. entry($_POST['T17'].product_id. exit.html"). $conn = mysql_connect("localhost". $ordersql = "select guest_id.$_POST['T8']). $gid = $_POST['gid']. entry($_POST['T13'].$conn). } } if($flg == 0) { header("Location: Afoodorder.quantity. echo "$day $month $year".$_POST['T6']).$_POST['T10']). function entry($fid. entry($_POST['T5'].$month. } entry($_POST['T1'].dayofmonth(date) as oday.$conn1) or die(mysql_error()). "root". $g1sql= "select * from guest where id = $gid1". $month = $date_array['mon']. $g1result = mysql_query($g1sql.$_POST['T4']).$_POST['T12']).$_POST['T16']). entry($_POST['T19'].$_POST['T14']). $gid1 = $_POST['gid']. $db1 = mysql_select_db("hotel". $day = $date_array['mday'].$day. entry($_POST['T7']. $conn) or die(mysql_error()).$conn1). "").$_POST['T20']). entry($_POST['T3']. entry($_POST['T11']. $flag = 0. while($g1 = mysql_fetch_array($g1result)) { if($gid1 == $g1['id']) { $flg = 1.$_POST['T2']). entry($_POST['T15'].4. $year = $date_array['year'].year(date) as oyear from ordersfood". $orderresult = mysql_query($ordersql. "root". $date1 = $year. while($order = mysql_fetch_array($orderresult)) { 15 . "").month(date) as omonth. $flg =0.$qty) { if($fid != 0 && $qty != 0) { $date_array = getdate(). Order Food: <?php $conn1 = mysql_connect("localhost".

$year1 = $order['oyear']. } } } if($flag == 0) { $orderfoodsql = "insert into ordersfood values(''. } } } } ?> 16 . } else { echo "something went wrong". $fid. header("Location: Frecorded. header("Location: Frecorded. $conn)) { echo "record added!". $guest = $order['guest_id'].$qty.$foodid = $order['product_id']. echo $qty.$gid. $updatesql = "update ordersfood set quantity = $qty where guest_id = $gid and product_id = $fid and date = current_timestamp". if (mysql_query($orderfoodsql. if (mysql_query($updatesql. } else { echo "something went wrong".html"). echo "$flag". $day1 = $order['oday'].html"). } if($gid == $guest && $foodid == $fid && $day == $day1 && $month == $month1 && $year == $year1) { $flag = 1.current_timestamp)". $month1 = $order['omonth']. if($day == $day1 && $month == $month1 && $year == $year1) { echo "hello". $qty += $order['quantity']. } else { echo "asdfasdf". $conn)) { echo "record modified!".

Inc. Generate Bill: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1. $row=mysql_fetch_row($s). if($y==0) print("database not selected").Copyright 2005 Macromedia. --> <title>Lodging . charset=iso-8859-1" /> <link rel="stylesheet" href="mm_lodging1.org/1999/xhtml"> <!-. if($t==0) print("wrong query 2"). ?> <body bgcolor="#999966"> 17 . $row2=mysql_fetch_row($u).0 Transitional//EN" "http://www. $r="select sum(rate*(quantity)) from (useservices natural join services) where (guest_id=$a)".""). $q="select sum((rate*(out_date-in_date)-advance)) from (alloted join room on alloted.room_no) where (guest_id=$a)".product_id) where (guest_id=$a)". All rights reserved.style7 {color: #CC0000} .style4 { font-size: x-large. $row1=mysql_fetch_row($t).room_no=room. $y=mysql_select_db("hotel".org/TR/xhtml1/DTD/xhtml1-transitional."root". $total=(double)($row[0]+$row1[0]+$row2[0]).product_id=menu. charset=iso-8859-1" /> <title>Untitled Document</title> </head> <? $a=(int)$_POST['textfield']. if($s==0) print("wrong query 1"). $x=mysql_connect("localhost".DW6 --> <head> <!-.Home Page</title> <meta http-equiv="Content-Type" content="text/html. $t=mysql_query($p).dtd"> <html xmlns="http://www. $u=mysql_query($r). if($x==0) print("unable 2 connect 2 database").w3.style10 {font-size: large} --> </style> <meta http-equiv="Content-Type" content="text/html.css" type="text/css" /> <style type="text/css"> <!-. $s=mysql_query($q).5. if($u==0) print("wrong query 3").w3.$x). } . $p="select sum(rate*(quantity)) from (ordersfood join menu on ordersfood. font-weight: bold.

</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"><img src="mm_spacer. <a href="contactUs.&nbsp.&nbsp.&nbsp.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#ffffff"> <td width="230" colspan="2" valign="top" bgcolor="#a4c2c2"> <img src="pic5.</td> <td width="200" class="sidebarText" id="padding">Hotel LandMark. Allahabad <br /> </td> <td width="15">&nbsp.&nbsp.&nbsp.</td> <td width="40">&nbsp.</td> <td height="36" colspan="3" id="navigation" class="navText"> <a href="homepage.&nbsp.&nbsp. <a href="reservation.&nbsp.&nbsp. <a href="rooms.jpg" /> <table border="0" cellspacing="0" cellpadding="0" width="230"> <tr> <td width="15">&nbsp.html">CONTACT</a>&nbsp. &nbsp.php"> 18 .&nbsp. &nbsp.&nbsp.&nbsp.&nbsp.gif" alt="" width="50" height="1" border="0" /></td> <td width="440" valign="top"> <table border="0" cellspacing="0" cellpadding="0" width="440"> <tr> <td class="pageName"><p class="style4">BILL</p></td> </tr> <tr></tr> </table> <form id="form1" method="post" action="trial.html">HOME</a>&nbsp.&nbsp.</td> </tr> </table> </td> <td width="50" valign="top"><img src="mm_spacer.&nbsp.<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15" nowrap="nowrap"><img src="mm_spacer.html">OUR ROOMS</a>&nbsp.html">MAKE A RESERVATION</a>&nbsp.</td> <td width="100%">&nbsp.</td> <td width="100%">&nbsp.&nbsp.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#a4c2c2"> <td width="15" nowrap="nowrap">&nbsp.&nbsp.&nbsp.&nbsp.</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"><img src="mm_spacer.jpg" alt="Home Page Image" width="210" height="210" border="0" lowsrc="pic5.&nbsp.gif" alt="" width="15" height="1" border="0" /></td> <td height="60" colspan="3" class="logo" nowrap="nowrap">HOTEL LANDMARK </td> <td width="40">&nbsp.&nbsp.

</label> <label> <label><br /> <br /> <br /> <br /> <br /> &nbsp.&nbsp.&nbsp.</strong>&n bsp.</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"><img src="mm_spacer.</td> <td width="40">&nbsp.&nbsp.&nbsp.</td> <td width="100%">&nbsp.Rs <? echo($total) ? ></span>.</td> <td width="440">&nbsp.</td> <td width="215">&nbsp.</td> </tr> </table> </body> </html> 19 .&nbsp.&nbsp.<strong>&nbsp.&nbsp.<label>&nbsp.&nbs p.&nbsp.&nbsp.&nbsp. left: 416px.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr> <td width="15">&nbsp."> </div> </label></form> </td> <td width="40">&nbsp.&nbsp. top: 325px.</td> <td width="100%">&nbsp.<span class="style10">&nbsp.&nbsp.</label> <br /> <div style="position:absolute.</td> <td width="50">&nbsp.&nbsp.<br /> <br /> <br /> <br /> <span class="style4" ><span class="style7"><font face="Arial Black">AMOUNT</span>:</span>&nbsp.

Output 1. Reservation Form: 2. Order Food: 20 .5.

Order Services: 21 .3. Menu: 4.

5. Bill: 22 .

Sign up to vote on this title
UsefulNot useful