Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //including the database connection file
- include_once("../config/config.php");
- if(isset($_POST['Submit'])) {
- $fileid2 = $_POST['fileid2'];
- $roomid = $_POST['roomid'];
- $prefixpri = $_POST['prefixpri'];
- $fnamepri = $_POST['fnamepri'];
- $lnamepri = $_POST['lnamepri'];
- $nationalitypri = $_POST['nationalitypri'];
- $extrabed = $_POST['extrabed'];
- $roomtype = $_POST['roomtype'];
- // checking empty fields
- if(empty($fileid2)) {
- if(empty($fileid2)) {
- echo "<font color='red'>Category field is empty.</font><br/>";
- }
- //link to the previous page
- echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
- } else {
- // if all the fields are filled (not empty)
- //insert data to database
- for ($i = 0; $i < count($_POST['fileid2']); $i++) {
- $fileid2 = $_POST['fileid2'][$i];
- $roomid = $_POST['roomid'][$i];
- $prefixpri = $_POST['prefixpri'][$i];
- $fnamepri = $_POST['fnamepri'][$i];
- $lnamepri = $_POST['lnamepri'][$i];
- $nationalitypri = $_POST['nationalitypri'][$i];
- $extrabed = $_POST['extrabed'][$i];
- //$roomtype = $_POST['roomtype'][$i];
- //insert info of pri guest to rez_client table
- $result = mysqli_query($mysqli, "INSERT INTO
- test (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`, `value7`)
- VALUES('$fileid2','$roomid','$prefixpri','$fnamepri','$lnamepri','$nationalitypri','$extrabed')");
- //insert info of pri guest to guestdetails table
- $result1 = mysqli_query($mysqli, "INSERT INTO
- testt (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`)
- VALUES('$fileid2','$roomid','$prefixpri','$fnamepri','$lnamepri','$nationalitypri')");
- //check if extrabed drop dwon is yes or no
- if($extrabed == 'Yes'){
- $fileid2ext = $_POST['fileid2'][$i];
- $roomidext = $_POST['roomid'][$i];
- $prefixext = $_POST['prefixext'][$i];
- $fnameext = $_POST['fnameext'][$i];
- $lnameext = $_POST['lnameext'][$i];
- $nationalityext = $_POST['nationalityext'][$i];
- $extrabed = $_POST['extrabed'][$i];
- //insert info of extrabed guest to guestdetails table (if extrabed is yes)
- $resultt = mysqli_query($mysqli, "INSERT INTO
- testt (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`)
- VALUES('$fileid2ext','$roomidext','$prefixext','$fnameext','$lnameext','$nationalityext')");
- }//close if
- else {
- //donothing;
- }
- }//close for
- ///////////////////////////////////////////////////
- if($roomtype == 'None'){
- //donothing;
- }
- elseif($roomtype == 'Single'){
- //donothing;
- }
- else{
- for ($x = 0; $x < count($_POST['roomid']); $x++) {
- $fileid2x = $_POST['fileid2'][$x];
- $roomidx = $_POST['roomid'][$x];
- $prefixx = $_POST['prefix'][$x];
- $fnamex = $_POST['fname'][$x];
- $lnamex = $_POST['lname'][$x];
- $nationalityx = $_POST['nationality'][$x];
- $resultt = mysqli_query($mysqli, "INSERT INTO
- testt (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`)
- VALUES('$fileid2x','$roomidx','$prefixx','$fnamex','$lnamex','$nationalityx')");
- }// close for
- }// close else
- //display success message
- echo "<font color='green'>Data added successfully.";
- echo "<br/><a href='2loopindex.php'>View Result</a>";
- }// close else
- }// close if isset
- ?>
- <?php
- //including the database connection file
- include_once("../config/config.php");
- //fetching data in descending order (lastest entry first)
- //$result = mysql_query("SELECT * FROM users ORDER BY id DESC"); // mysql_query is deprecated
- $resultagency = mysqli_query($mysqli, "SELECT * FROM agency ORDER BY id DESC"); // using mysqli_query instead
- $reshotlnam = mysqli_query($mysqli, "SELECT * FROM hotels ORDER BY id DESC"); // using mysqli_query instead
- $resromtyp = mysqli_query($mysqli, "SELECT * FROM roomtype ORDER BY id"); // using mysqli_query instead
- $resroomcat = mysqli_query($mysqli, "SELECT * FROM roomcat ORDER BY id DESC"); // using mysqli_query instead
- $resboard = mysqli_query($mysqli, "SELECT * FROM board ORDER BY id DESC"); // using mysqli_query instead
- $resulttours = mysqli_query($mysqli, "SELECT * FROM tours ORDER BY id DESC"); // using mysqli_query instead
- $resulttransfers = mysqli_query($mysqli, "SELECT * FROM transfers ORDER BY id DESC"); // using mysqli_query instead
- // code to generate File ID
- $gen_fileid = mysqli_query($mysqli, "SELECT max(fileid) FROM rez_file_info ORDER BY fileid DESC LIMIT 1;");
- if (mysqli_num_rows($gen_fileid) > 0) {
- $max_fileid = mysqli_fetch_row($gen_fileid);
- //echo $max_fileid[0]; //Here it is
- $generated_fileid =$max_fileid[0] +1;
- }
- ?>
- <script src="../scripts/teknocave-js.js" type="text/javascript"></script>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script type="text/javascript">
- function GetDays(target){
- var dropdt = new Date($(target).find(".drop_date").val());
- var pickdt = new Date($(target).find(".pick_date").val());
- return parseInt((dropdt - pickdt) / (24 * 3600 * 1000));
- }
- function cal(target){
- console.log($(target).parent(), $(target).parent().find('numdays2'));
- $(target).parent().find('.numdays2').val(GetDays($(target).parent()));
- }
- </script>
- <script type="text/javascript">
- $(document).ready(function() {
- var genroomid = 2; // change 0 to the number you want to start with
- $(".add-row").click(function() {
- var $clone = $("ul.personal-details").first().clone();
- var $input = $clone.find('#roomid');
- $input.val(genroomid).attr('genroomid', +genroomid) // change fileid with any string you want
- $clone.append("<button type='button' class='remove-row'>-</button>");
- $clone.insertBefore(".add-row");
- genroomid++; // increase id by 1
- });
- $(".cloned-removed-div").on("click", ".remove-row", function() {
- $(this).parent().remove();
- genroomid--;
- });
- //code of display guest info
- // var codes of Primary Guest info
- var blkofcod1pri = "<select class='stretch' name='prefixpri[]'><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Child'>Child</option><option value='Infant'>Infant</option></select>";
- var blkofcod2pri = "<input name='fnamepri[]' type='text' class='stretch' placeholder='First Name' size='15' maxlength='30' required > <input name='lnamepri[]' type='text' class='stretch' placeholder='Last Name' size='15' maxlength='30' required >";
- var blkofcod3pri = "<input name='nationalitypri[]' type='text' placeholder='Nationality' class='stretch' size='15' maxlength='30' required >";
- // var codes of other Guest info in same room
- var blkofcod1 = "<select class='stretch' name='prefix[]'><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Child'>Child</option><option value='Infant'>Infant</option></select>";
- var blkofcod2 = "<input name='fname[]' type='text' class='stretch' placeholder='First Name' size='15' maxlength='30' required > <input name='lname[]' type='text' class='stretch' placeholder='Last Name' size='15' maxlength='30' required >";
- var blkofcod3 = "<input name='nationality[]' type='text' placeholder='Nationality' class='stretch' size='15' maxlength='30' required >";
- // var codes of other Guest info of extra bed
- var blkofcod1ext = "<select class='stretch' name='prefixext[]'><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Child'>Child</option><option value='Infant'>Infant</option></select>";
- var blkofcod2ext = "<input name='fnameext[]' type='text' class='stretch' placeholder='First Name' size='15' maxlength='30' required > <input name='lnameext[]' type='text' class='stretch' placeholder='Last Name' size='15' maxlength='30' required >";
- var blkofcod3ext = "<input name='nationalityext[]' type='text' placeholder='Nationality' class='stretch' size='15' maxlength='30' required >";
- $(document).on('change', '#roomtype', function() {
- var value = $(this).val();
- var toAppend = '';
- var $container = $(this).siblings('#container')
- switch (value) {
- case 'None':
- toAppend = $container.html(toAppend);
- return;
- break;
- case 'Single':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri;
- $container.html(toAppend);
- return;
- break;
- case 'Double':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Triple':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Quadruple':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Quintuple(5)':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Sextuple(6)':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Septuple(7)':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Octuple(8)':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Nonuple(9)':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- case 'Decuple(10)':
- toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
- $container.html(toAppend);
- return;
- break;
- default:
- toAppend = $container.html(toAppend);
- return;
- }
- });
- // code of display guest info of extra bed
- $(document).on('change', '#extrabed', function() {
- var value2 = $(this).val();
- var toAppend2 = '';
- var $container2 = $(this).siblings('#container2')
- switch (value2) {
- case 'No':
- toAppend2 = $container2.html(toAppend2);
- return;
- break;
- case 'Yes':
- toAppend2 = blkofcod1ext + blkofcod2ext + blkofcod3ext;
- $container2.html(toAppend2);
- return;
- break;
- default:
- toAppend2 = $container2.html(toAppend2);
- return;
- }
- });
- });
- </script>
- <!--<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
- <script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>-->
- <!DOCTYPE html><html lang="en">
- <head>
- <body>
- <form name="form_reservations" method="post" action="2loopadd.php">
- <div class="cloned-removed-div">
- <ul class="personal-details">
- <table class="stretch" border="1">
- <tr>
- <!--<td>File ID</td>-->
- <td>TEST</td>
- <td>TEST</td>
- </tr>
- <tr>
- <td>
- <label for="fileid2">FileID</label>
- <input name="fileid2[]" type="text" class="stretchnights" id="fileid2" >
- <label for="roomid">RoomID</label>
- <input name="roomid[]" type="text" class="stretchnights" id="roomid" readonly="readonly" value="1">
- </td>
- <td>
- <div>
- <select class="stretch" id="roomtype" name="roomtype[]" required="required">
- <option value="">Room Type</option>
- <option value="None">None </option>
- <?php
- foreach ($resromtyp as $row3) {
- echo '<option value="' . $row3['name'] . '">' . $row3['name'] . '</option>';
- }
- ?>
- </select>
- <div id="container"></div>
- <label for="extrabed">Extra Bed
- <select class="stretch" name="extrabed[]" id="extrabed" required="required">
- <option value=""> </option>
- <option value="No">No</option>
- <option value="Yes">Yes</option>
- </select>
- <div id="container2"></div></label>
- </div>
- </td>
- </tr>
- <tr><td colspan="6">
- <label for="note2">Note:
- <textarea name="note2[]" style="width:100%;" ></textarea></label>
- </td></tr>
- </table>
- </ul>
- <button type="button" class="add-row" >+ New Client</button>
- <table width="25%" border="0"> <tr> <input type="submit" name="Submit" value="Insert"></tr></table>
- </div>
- </form>
- </body>
- </head>
Add Comment
Please, Sign In to add comment