0
<form action= '1stform.php' method = "POST">
<fieldset border = "5">
<table>
<tr>
<td>Check Availability</td>
</tr>
<tr><td>
  <p>Garden Room:
    </label>
    <select name="room_GR">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
      <option value="10">10</option>
      <option value="11">11</option>
      <option value="12">12</option>
      <option value="13">13</option>
      <option value="14">14</option>
      <option value="15">15</option>
      <option value="16">16</option>
      <option value="17">17</option>
      <option value="18">18</option>
      <option value="19">19</option>
      <option value="20">20</option>
      
    </select>
    <br />
    Ocean/Pool View Room:
    </label>
    <select name="room_OPVR">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
      <option value="10">10</option>
    </select>
    <br />
    Ocean/Pool View Suite:
    </label>
    <select name="room_OPVS">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
    </select>
    <br />
	Rest House:
    </label>
    <select name="room_RH">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      
    </select>
    <br />
    Check-Out Date: 
    <select name="month_out">
      <option value="01">January</option>
      <option value="02">February</option>
      <option value="03">March</option>
      <option value="04">April</option>
      <option value="05">May</option>
      <option value="06">June</option>
      <option value="07">July</option>
      <option value="08">August</option>
      <option value="09">September</option>
      <option value="10">October</option>
      <option value="11">November</option>
      <option value="12">December</option>
    </select>
    <select name="date_out">
    <option selected="selected" value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

    </select>
    
    <select name="check_out_year">
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2012">2013</option>
<option value="2012">2014</option>
<option value="2012">2015</option>
<option value="2012">2016</option>
<option value="2012">2017</option>

    <br />
  Check-In Date: 
    <select name="month_in">
      <option value="01">January</option>
      <option value="02">February</option>
      <option value="03">March</option>
      <option value="04">April</option>
      <option value="05">May</option>
      <option value="06">June</option>
      <option value="07">July</option>
      <option value="08">August</option>
      <option value="09">September</option>
      <option value="10">October</option>
      <option value="11">November</option>
      <option value="12">December</option>
    </select>
    <select name="date_in">
    <option selected="selected" value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

    </select>
    
    <select name="check_in_year">
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2012">2013</option>
<option value="2012">2014</option>
<option value="2012">2015</option>
<option value="2012">2016</option>
<option value="2012">2017</option>

    
    <br />
    Number of Adults: 
    </label>
    <select name="num_adults">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
    </select>
    
    <br />
    Number of Children: 
    </label>
    <select name="num_children">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
    </select>
    </p>
  <p>
    <input type="submit" value="Check Availability" name="submit" />
    
    
    
    </p></td></tr>
</table>

this the post code

<title>Untitled Document</title>
</head>

<body>
<p>
  <?php

$check_indate = $_POST['check_in_year']."-".$_POST['month_in']."-".$_POST['date_in'];
$num_nights = $_POST['num_nights'];
$room_GR = $_POST['room_GR'];
$room_OPVR = $_POST['room_OPVR'];
$room_OPVS = $_POST['room_OPVS'];
$room_RH = $_POST['room_RH'];
$num_adults = $_POST['num_adults'];
$num_child = $_POST['num_children'];
$a = $_POST['date_in'] + $_POST['num_nights'];
$cout_date = $_POST['check_in_year']."-".$_POST['month_in']."-".$a;
$cdate = strtotime($cout_date);
$chdate = strtotime($check_indate);
$room_need_GR = 0;
$room_need_OPVR = 0;
$room_need_OPVS = 0;
$room_need_RH = 0;
session_start();

$_SESSION['checkin_date'] = $check_indate;
$_SESSION['cout_date'] = $cout_date;
$_SESSION['room_GR1'] = $room_GR;
$_SESSION['room_OPVR1'] = $room_OPVR;
$_SESSION['room_OPVS1'] = $room_OPVS;
$_SESSION['room_RH1'] = $room_RH;
$_SESSION['checkin_date'] = $check_indate;
$_SESSION['night_num'] = $_POST['num_nights'];
$_SESSION['adult_num'] = $num_adults;
$_SESSION['child_num'] = $num_child;



if ($room_GR != 0) {
for($room_no = 1; $room_no<=20; $room_no++)
{
	$conn=mysql_connect("localhost","root","");
	$select_db = mysql_select_db("kahuna");
	
	$dbquery = "select  * from rooms where room_id = '".$room_no."' and rm_type = 'Garden Room' and date_checkin <= '".$check_indate."' and date_checkout >= '".$cout_date."'";
	 
	$result = mysql_query($dbquery);
	
	if (mysql_num_rows($result) == 0)
	{
		//echo $room_no." is available - garden room <br />";
		$_SESSION['room_del'][]=$room_no;
		$room_need_GR++;
	}
	else
	{
		//echo $room_no." is not available - garden room <br />";
	}
	if ($room_need_GR == $room_GR)
	{
		break;
	}

}
}
echo "<br /><br />";

$room_need_OPVR = 0;
if ($room_OPVR != 0) {
for($room_no = 1; $room_no<=8; $room_no++)
{
	$conn=mysql_connect("localhost","root","");
	$select_db = mysql_select_db("kahuna");
	
	$dbquery = "select  * from room_reservation where room_id = '".$room_no."' and rm_type = 'Ocean/Pool View Room' and date_checkin <= '".$check_indate."' and date_checkout >= '".$cout_date."'";
	 
	$result = mysql_query($dbquery);
	
	if (mysql_num_rows($result) == 0)
	{
		//echo $room_no." is available - Ocean/Pool View Room <br />";
		$_SESSION['room_OPVRl'][]=$room_no;
		$room_need_OPVR++;
	}
	else
	{
		//echo $room_no." is not available - Ocean/Pool View Room <br />";
	}
	if ($room_need_OPVR == $room_OPVR)
	{
		break;
	}

}
}

$room_need_OPVS = 0;
if ($room_OPVS != 0) {
for($room_no = 1; $room_no<=8; $room_no++)
{
	$conn=mysql_connect("localhost","root","");
	$select_db = mysql_select_db("kahuna");
	
	$dbquery = "select  * from room_reservation where room_id = '".$room_no."' and rm_type = 'Ocean/Pool View Suite' and date_checkin <= '".$check_indate."' and date_checkout >= '".$cout_date."'";
	 
	$result = mysql_query($dbquery);
	
	if (mysql_num_rows($result) == 0)
	{
		//echo $room_no." is available - Ocean/Pool View Suite <br />";
		$_SESSION['room_OPVSl'][]=$room_no;
		$room_need_OPVS++;
	}
	else
	{
		//echo $room_no." is not available - Ocean/Pool View Suite <br />";
	}
	if ($room_need_OPVS == $room_OPVS)
	{
		break;
	}

}
}
$room_need_RH = 0;
if ($room_RH != 0) {
for($room_no = 1; $room_no<=8; $room_no++)
{
	$conn=mysql_connect("localhost","root","");
	$select_db = mysql_select_db("kahuna");
	
	$dbquery = "select  * from room_reservation where room_id = '".$room_no."' and rm_type = 'Rest House' and date_checkin <= '".$check_indate."' and date_checkout >= '".$cout_date."'";
	 
	$result = mysql_query($dbquery);
	
	if (mysql_num_rows($result) == 0)
	{
		//echo $room_no." is available - RH <br />";
		$_SESSION['room_RHl'][]=$room_no;
		$room_need_RH++;
	}
	else
	{
		//echo $room_no." is not available - Rest House <br />";
	}
	if ($room_need_RH == $room_RH)
	{
		break;
	}

}
}



?>
</p>
<p>&nbsp;</p>
</body>
</html>

help me how to insert some files please

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by diafol
0

Have a look at the upload file section in the php manual. BTW, you'd be better off with a date picker for the dates as you can't stop an user giving the 31st of Feb!

You don't seem, to be sanitizing the input.

There's a lot of code duplication.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.