Booking system database entry problem
Posted: Fri Sep 23, 2005 7:52 am
Hi all,
Basically I have a booking form which users fill in and select a date and time for booking, either by clicking on the calendar or selecting in combo boxes. The date selection works fine and enters the users selection into the combo box however, the problem is that the time is not being inserted into the database and as such not create a booking. I've gone through it and I'm obviously missing something...?
Pages: book.php and insertdata.php
Any help would be much appreciated.
Simon.
have used phpinfo and the value of combo box 'tourstarttime' is being passed from book.php to inserdata.php. So the problem is somewhere in insertdata.php.
After being passed the value is assigned as:
Some validation is then done to ensure a time was selected:
We then check that tour exists:
We then check tour avaliability:
We then look for a database record time matching our session variable:
We then enter user data into user table which works fine then the tour_time data into options
Thats it the rest of the page is confirmation and error messages, so the problems got to be here some where... Any ideas anyone?
Any help will be much appreciated!!!
Simon.
Basically I have a booking form which users fill in and select a date and time for booking, either by clicking on the calendar or selecting in combo boxes. The date selection works fine and enters the users selection into the combo box however, the problem is that the time is not being inserted into the database and as such not create a booking. I've gone through it and I'm obviously missing something...?
Pages: book.php and insertdata.php
Any help would be much appreciated.
Simon.
have used phpinfo and the value of combo box 'tourstarttime' is being passed from book.php to inserdata.php. So the problem is somewhere in insertdata.php.
After being passed the value is assigned as:
Code: Select all
$_SESSION['tourstarttime'] = strip_tags($_POST['tourstarttime']);Code: Select all
elseif ($_SESSION['tourstarttime'] == "") { $form_error = true; $_SESSION['form_error_text'] = "Please enter a campus tour time.";Code: Select all
$query_date = 2005-".$_SESSION['tourmonth']."-".$_SESSION['tourday'];
$query_tour = "SELECT * FROM `tours`,`tourtimes` ".
"WHERE `tours`.`tour_date`='".$query_date."' ".
"AND `tourtimes`.`tour_id`=`tours`.`tour_id`";
$query_tour_result = @mysql_query($query_tour);Code: Select all
while ($tour = mysql_fetch_array($query_tour_result))
{
$query_available_time = "SELECT SUM(`users`.`user_partysize`) AS `count` FROM `users`, `options` WHERE `options`.`tourtime_id`='".$tour['tourtime_id']."' ".
"AND `users`.`user_id`=`options`.`user_id`";
$count_result = @mysql_query($query_available_time);
$count = mysql_fetch_array($count_result);
$numberofbookings = ($count['count']==0)?0:$count['count'];
$online_capacity = round($tour['tour_capacity']*$capacity_threshold);
$available_spaces[] = $online_capacity - $numberofbookings;
if ($available_spaces[$counter] <= 0) $_SESSION[$tour['tourtime_starttime']] = "full";
else $_SESSION[$tour['tourtime_starttime']] = "available";Code: Select all
if ($tour['tourtime_starttime'] == $_SESSION['tourstarttime'])
{
//if ($available_spaces[$counter] == 20)
if ($available_spaces[$counter] <= 0)
{
$form_error = true;
$_SESSION['form_timeslot_full'] = true;
$_SESSION['form_error_text'] = "No spaces available for the ".substr_replace($_SESSION['tourstarttime'],"",-3)." tour.";
} else
{
$timeid = $tour['tourtime_id'];
$bookedtimeslot = substr_replace($_SESSION['tourstarttime'],"",-3);
}
}
$counter++;
}We then enter user data into user table which works fine then the tour_time data into options
Code: Select all
$userid = mysql_insert_id();
$insert_data_query = "INSERT INTO `options` ( `user_id`, `tourtime_id`) ".
"VALUES ('".$userid."', '".$timeid."')";
//echo $insert_data_query;
if (!($result=@mysql_query($insert_data_query))) $insert_intodb_result="data_insert_error"; // output error (e.g. duplicate account)
}Thats it the rest of the page is confirmation and error messages, so the problems got to be here some where... Any ideas anyone?
Any help will be much appreciated!!!
Simon.