Jump to content

Booking form problem


denhamd2

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.