Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to do Booking Form in html containing the inputs as follows - check in date

ID: 3715879 • Letter: H

Question

How to do Booking Form in html containing the inputs as follows - check in date - check out date - room name - type of room - number of persons - username - email - phone number - Total cost
And after creating a table in PHPmyadmin called Book, how can I write the php and html code that will check all the inputs in database if the date at given room is available or not ? How to do Booking Form in html containing the inputs as follows - check in date - check out date - room name - type of room - number of persons - username - email - phone number - Total cost
And after creating a table in PHPmyadmin called Book, how can I write the php and html code that will check all the inputs in database if the date at given room is available or not ? How to do Booking Form in html containing the inputs as follows - check in date - check out date - room name - type of room - number of persons - username - email - phone number - Total cost
And after creating a table in PHPmyadmin called Book, how can I write the php and html code that will check all the inputs in database if the date at given room is available or not ? - check in date - check out date - room name - type of room - number of persons - username - email - phone number - Total cost
And after creating a table in PHPmyadmin called Book, how can I write the php and html code that will check all the inputs in database if the date at given room is available or not ?

Explanation / Answer

''''''''Database - hotel. ''''''''''''''''' Tablename = book

CREATE TABLE `hotel`.`book` (
`id` INT NOT NULL AUTO_INCREMENT,
`InDate` DATETIME NULL,
`OutDate` DATETIME NULL,
`RoomName` VARCHAR(45) NULL,
`RoomType` VARCHAR(45) NULL,
`NoOfPersons` VARCHAR(45) NULL,
`UName` VARCHAR(45) NULL,
`Email` VARCHAR(45) NULL,
`Ph` VARCHAR(45) NULL,
`Cost` VARCHAR(45) NULL,
PRIMARY KEY (`id`));

------------------------------------------- HTML FORM = bookroom.html--------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Book Room</title>

<style type="text/css">

<!--

body {

background-color: #FFFFFF;

}

.style1 {

color: #000000;

font-weight: bold;

}

.style3 {font-family: "Courier New", Courier, monospace}

-->

</style></head>

<body>

<div align="center">

<table width="580" border="0">

<tr>

<td width="640" height="465"><table width="547" border="0" align="center">

<tr>

<td>

<form method="get" action="bookroom.php">

<table width="367" height="422" border="1" align="center" cellspacing="0" bordercolor="#000000">

<tr bgcolor="#FFCC99">

<td colspan="2"><div align="center" class="style1">Book a Hotel Room </div></td>

</tr>

<tr bgcolor="#66FFFF">

<td width="138" bgcolor="#FFFFCC"><div align="right"><span class="style3">CheckIN Date:</span></div></td>

<td width="182" bgcolor="#FFFFFF"><label>

&nbsp;&nbsp;

<input type="date" name="dpIn" id="dpIn"/>

</label></td>

</tr>

<tr bgcolor="#66CCFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">Check OUT Date:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input type="date" name="dpOut" id="dpOut" /></td>

</tr>

<tr bgcolor="#66FFFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">Room Name:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtRoomName" type="text" id="txtRoomName" /></td>

</tr>

<tr bgcolor="#66FFFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">Type of Room:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtRoomType" type="text" id="txtRoomType" /></td>

</tr>

<tr bgcolor="#66FFFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">No of Persons:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtNo" type="text" id="txtNo" /></td>

</tr>

<tr bgcolor="#66CCFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">User Name:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtUName" type="text" id="txtUName" /></td>

</tr>

<tr bgcolor="#66CCFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">Email:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtEmail" type="text" id="txtEmail" /></td>

</tr>

<tr bgcolor="#66CCFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">Phone:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtPh" type="text" id="txtPh" /></td>

</tr>

<tr bgcolor="#66CCFF">

<td bgcolor="#FFFFCC"><div align="right"><span class="style3">Total Cost:</span></div></td>

<td bgcolor="#FFFFFF">&nbsp;&nbsp;

<input name="txtCost" type="text" id="txtCost" /></td>

</tr>

<tr>

<td colspan="2"><label>

<div align="center">

<input type="submit" name="button2" id="button2" value="Book Room" />

<label>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" name="Reset" id="button" value="Reset" />

&nbsp; </label>

</div>

</label></td>

</tr>

</table>

</form> </td>

</tr>

</table>

</td>

</tr>

</table>

</div>

</body>

</html>

------------------------------------------- php = bookroom.php --------------------------------------------------------------

<?php

$inDate=$_GET["dpIn"];
$outDate=$_GET["dpOut"];
$roomName=$_GET["txtRoomName"];
$roomType=$_GET["txtRoomType"];
$No=$_GET["txtNo"];
$uname=$_GET["txtUName"];
$email=$_GET["txtEmail"];
$ph=$_GET["txtPh"];
$cost=$_GET["txtCost"];


$conn=mysql_connect("localhost","root","root");

mysql_select_db("hotel");

$res=mysql_query("select * from book where RoomName='$roomName' AND ((InDate Between '$inDate' AND '$outDate') or (OutDate Between '$inDate' AND '$outDate') ) or (InDate<='$inDate' AND OutDate>='$outDate')");
if($row=mysql_fetch_row($res)){

print "<font color=red size=5><center>This Room is Already Reserved. Please select a different Room</center></font>";
}else{
mysql_query("insert into book values(null,'$inDate','$outDate','$roomName','$roomType','$No','$uname','$email','$ph','$cost')");
print "<font color=blue size=6><center>Room Sucessfully Booked</center></font>";
}

mysql_close($conn);

?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote