Knuckles Posted April 15, 2010 Share Posted April 15, 2010 Hello, I am making an reservation script wich i cant seem to figure out how to get it too check that if 1 house is ordered in sertend time. that is doesnt double reserve it and after the period it can but it may book another house in the time the other is booked. Script Attached Greetz Knuckles [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
efficacious Posted April 15, 2010 Share Posted April 15, 2010 I couldn't understand the script posted. You need to assign a flag of some sort. Here is how I would handle this... I would create 3 columns in the database Resrv_Start Resrv_End Reserved Then populate the database with the appropriate information: A timestamp for the time the house was first Reserved A projected timestamp for the time the house is to be empty. A flag to quickly determine if the house is reserved. After that you can just run simple php script to work with the information to obtain the result needed. Quote Link to comment Share on other sites More sharing options...
Knuckles Posted April 15, 2010 Author Share Posted April 15, 2010 i posted script so u can see what i mean and maybe add slight change or so cause im stuck Quote Link to comment Share on other sites More sharing options...
efficacious Posted April 15, 2010 Share Posted April 15, 2010 i posted script so u can see what i mean and maybe add slight change or so cause im stuck I don't understand the variable names in the script so i can't read it. Quote Link to comment Share on other sites More sharing options...
Knuckles Posted April 15, 2010 Author Share Posted April 15, 2010 Ill repost the script with other variable`s names to english Quote Link to comment Share on other sites More sharing options...
Knuckles Posted April 15, 2010 Author Share Posted April 15, 2010 Here is one with a bit explained in it. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Knuckles Posted April 16, 2010 Author Share Posted April 16, 2010 Can someone help me out? // Script edited to english. Except for the options that are shown. <?php session_start(); include("config.php"); if (!empty($_POST)){ $arrivalday = mysql_real_escape_string($_POST["arrivalday"]); $arrivalmonth = mysql_real_escape_string($_POST["arrivalmonth"]); $arrivalyear = mysql_real_escape_string($_POST["arrivalyear"]); $leaveday = mysql_real_escape_string($_POST["leaveday"]); $leavemonth = mysql_real_escape_string($_POST["leavemonth"]); $leaveyear = mysql_real_escape_string($_POST["leaveyear"]); $house = mysql_real_escape_string($_POST["house"]); $query = "SELECT * FROM reserve WHERE house >='". $house ."' AND arrivalday >='". $arrivalday ."' AND arrivalmonth >= '". $arrivalmonth ."' AND arrivalyear >= '". $arrivalyear ."' AND leaveday <= '". $leaveday ."' AND leavemonth <= '". $leavemonth ."' AND leaveyear <= '". $leaveyear ."'"; $check = mysql_query($query) or die ("FOUT: " . mysql_error().$query); while ($row = mysql_fetch_array($check)){ $check2[] = $row; } if( count($check2) == 0 ) { $reserve = "INSERT INTO reserve(customernumber, customername, house, arrivalday, arrivalmonth, arrivalyear, leaveday, leavemonth, leaveyear)"; $reserve .= "VALUES ('"; $reserve .= $_POST["customernumber"] ."', '"; $reserve .= $_POST["customername"] ."', '"; $reserve .= $_POST["house"] ."', '"; $reserve .= $_POST["arrivalday"] ."', '"; $reserve .= $_POST["arrivalmonth"] ."', '"; $reserve .= $_POST["arrivalyear"] ."', '"; $reserve .= $_POST["leaveday"] ."', '"; $reserve .= $_POST["leavemonth"] ."', '"; $reserve .= $_POST["leaveyear"] ."');" ; $verzenden = mysql_query ($reserve) or die(mysql_error()); $customernumber = $_POST["customernumber"]; $customername = $_POST["customername"]; $house = $_POST["house"]; $arrivalday = $_POST["arrivalday"]; $arrivalmonth = $_POST["arrivalmonth"]; $arrivalyear = $_POST["arrivalyear"]; $leaveday = $_POST["leaveday"]; $leavemonth = $_POST["leavemonth"]; $leaveyear = $_POST["leaveyear"]; $_SESSION["customernumber"]; $_SESSION["customername"]; $_SESSION["house"]; $_SESSION["arrivalday"]; $_SESSION["arrivalmonth"]; $_SESSION["arrivalyear"]; $_SESSION["leaveday"]; $_SESSION["leavemonth"]; $_SESSION["leaveyear"]; } else { exit; } } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Home</title> <meta name="Description" content="Model blog" /> <meta name="#" content="#" /> <script type="text/javascript"> function openpopup(popurl){ var winpops=window.open(popurl,"","width=400,height=400") } </script> <style type="text/css"> <!-- @import"style.css"; --> </style> </head> <body class="wrapper"> <div id="container"> <div id="header"></div> <div id="menu"> <ul> <li><a href="index2.php" title="Home"><span>Home</span></a></li> <li><a href="vakantiehousejes.php" title="Vakantiehousejes"><span>Vakantiehousejes</span></a></li> <li id="csslibrarytab"><a href="reserve.php" title="reserve"><span>reserve</span></a></li> <?php if (!isset($_SESSION["username"])){ echo "<li><a href=javascript:login('show') title=Login><span>Login</span></a></li>"; }else{ echo ("<li><a href=profiel.php title=Profiel><span>Profiel</span></a></li>"); echo ("<li><a href=logout.php title=Logout><span>Logout</span></a></li>"); } ?> <li><a href="admin/adminpanel.php" title="Admin"><span>Admin Paneel</span></a></li> </ul> </div> <div class="clearfloat"></div> <div id="mainContent"> <div class="leftcont"> <div class="rightcont"> <h2>Reservation</h2> </div></div> <form name="form1" method="post" action="<?php echo($_SERVER["PHP_SELF"]);?>"> <center> <table width="350" height="150" border="0"> <tr> <td width="53">House:</td> <td width="260"><select name="house"> <option value="House 1">House 1</option> <option value="House 2">House 2</option> <option value="House 3">House 3</option> </select></td> </tr> <tr> <td>customername:</td> <td><input name="customername" type="text" size="30" maxlength="40" /></td> </tr> <tr> <td>Arrival date:</td> <td><select name="arrivalday"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</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="arrivalmonth"> <option value="januari">Januari</option> <option value="febuari">Februari</option> <option value="maart">Maart</option> <option value="april">April</option> <option value="mei">Mei</option> <option value="juni">Juni</option> <option value="juli">Juli</option> <option value="augustus">Augustus</option> <option value="september">September</option> <option value="oktober">Oktober</option> <option value="november">November</option> <option value="december">December</option> </select> - <select name="arrivalyear"> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select></td> </tr> <tr> <td>Leaving date:</td> <td><select name="leaveday"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</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="leavemonth"> <option value="januari">Januari</option> <option value="febuari">Februari</option> <option value="maart">Maart</option> <option value="april">April</option> <option value="mei">Mei</option> <option value="juni">Juni</option> <option value="juli">Juli</option> <option value="augustus">Augustus</option> <option value="september">September</option> <option value="oktober">Oktober</option> <option value="november">November</option> <option value="december">December</option> </select> - <select name="leaveyear"> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select> </td> </tr> </table> <p> </p> <input type="submit" name="submit" value="reserve"> <input name="reset" type="reset" value="Empty"> </center> </form> </div> <br class="clearfloat" /> <div id="footer"> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
efficacious Posted November 24, 2010 Share Posted November 24, 2010 Now that I can read the script.. All you need to do is a cross check on the database information and the dates to see if the date for the house to be scheduled is in use. If the dates don't cross-over one another then your good and proceed with the reservation.. in code: if (ArrivalDate == LeaveDate) { echo("Error!: The Arrival Date entered conflicts with a previous reservation. Please choose a later date."); } else { //Code to enter reservation into database } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.