Jump to content

Recommended Posts

Hi,

 

I have a set up a booking form with 2 calendars for 2 houses:

http://www.aholidayinspain.net/booking/index-booker.php

 

It basically collects the dates selected, goes to a confirmation page where it just echos the dates and then on the third page it inserts it into the database tables, house 1's table is called "bookings" and house 2's table is called "house2bookings". However, when you try to book a date for 1 of the houses it actually inserts the date into both of the tables because it just inserts all the session variables we have collected into both. Is there any way I can separate the house 2 bookings from the house 1 ones and then insert them into the separate tables? Bear in mind that all house 2 variable names start with "house2" on the form on page 1.

 

Here is my PHP code:

 

<?php
// Get all the session variables stored in the previous page:
$un_neces_varible = array('contactsubmit');

  foreach($_SESSION['DATA'] as $v) {
               if(!in_array($key,$un_neces_varible)){


     mysql_query("INSERT INTO bookings 
(date, theuserid) VALUES('$v','$recentuser') ") 
or die(mysql_error());  
  }
  }

?>
<?php
// Get all the session variables stored in the previous page:
$un_neces_varible = array('contactsubmit');

  foreach($_SESSION['DATA'] as $v) {
               if(!in_array($key,$un_neces_varible)){


     mysql_query("INSERT INTO house2bookings 
(house2date, house2theuserid) VALUES('$v','$recentuser') ") 
or die(mysql_error());  
  }
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/51637-booking-form-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.