Hi opengeek,
thanks for the help and support...the community has been great
ok so here is the snippet, its not huge and I am sure the code will sicken many a good coder.....but it works!!!
so to explain the problem again. If I post to addParticipant.html....i get redirected. However if I post to addParticipant page ID all is well!!!???!!!
addParticipant (builds up a form to add names etc):
<?php
//Create a new instance of the databaseAPI. Connect to our training DB.
$mydb= new DBAPI();
$mydb->connect($host='a host',$dbase='a db', $uid='a user',$pwd='a password');
//First off check if a discount code was posted by the user.
if (isset($_POST['discount_Code'])) {
$search = $_POST['discount_Code'];
$query_viewCode = "SELECT * FROM discount WHERE discount_Code = '$search'";
$viewCode = $mydb->query($query_viewCode);
$row_viewCode = mysql_fetch_assoc($viewCode);
$totalRows_viewCode = mysql_num_rows($viewCode);
//IF THE CODE WAS FOUND ALLOW THE DISCOUNT ELSE BOOT TO THE ERROR PAGE.
if ($search != "") {
if($totalRows_viewCode > 0) {
$_SESSION['specialDiscountCode'] = $search;
}else{
$modx->sendRedirect("codeerror.html");
exit;
}
}
}
//Now we select the course to be booked.
if (isset($_POST["courses"])) {
$courseprice = $_POST["courses"];
$query_checkPrice = "SELECT course_Price FROM courses WHERE course_ID = $courseprice";
$checkPrice = $mydb->query($query_checkPrice);
$row_checkPrice = mysql_fetch_assoc($checkPrice);
$totalRows_checkPrice = mysql_num_rows($checkPrice);
$_SESSION['courseID'] = $_POST["courses"];
$_SESSION['eventID'] = $_POST["dates"];
$_SESSION['participantNumber'] = $_POST["participants"];
$participants = $_SESSION['participantNumber'];
$eventID = $_SESSION['eventID'];
//Do a quick check for the total number of bookings for the selected event.
//Count the number of bookings for the selected event
$query_countEvent = "SELECT count(booking_ID) as eventCount FROM booking WHERE event_ID = '$eventID'";
$countEvent = $mydb->query($query_countEvent);
$row_eventCount = mysql_fetch_assoc($countEvent);
$eventCount = $row_eventCount["eventCount"];
//Now check event count againist the number of seats left
$query_checkMax = "SELECT event_Max FROM event WHERE event_ID = '$eventID'";
$checkMax = $mydb->query($query_checkMax);
$row_checkMax = mysql_fetch_assoc($checkMax);
$eventMax = $row_checkMax["event_Max"];
//Now determine the amount of seats left on course
$seatsLeft = $eventMax - $eventCount;
//If the number of seats requested are not available, then re-diret the user to an error page
if ($participants > $seatsLeft) {
$modx->sendRedirect("coursefull.html");
}
$price = $row_checkPrice["course_Price"];
$price = $price*$participants;
//Get rid of the change or realex will explode.
$price = round($price,0);
$_SESSION['price'] = $price;
}else{
//Because this page is dynamic we need to redirect to stop session errors for the back button is clicked.
$modx->sendRedirect("booking.html");
}
//If they have got this far without a re-direct build up the form for them to enter details and output.
$i=1;
$out = 2;
$output = "";
while($i < $participants) {
$output .= "<p><strong>Participant # $out </strong></p>";
$output .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"27%\">First Name: *</td>";
$output .= "<td width=\"70%\" height=\"30\"><input name=\"namep$i\" type=\"text\" id=\"namep$i\" size=\"22\">";
$output .= "</td></tr><tr><td>Family Name: *</td><td height=\"30\"><input name=\"snamep$i\" type=\"text\" id=\"snamep\" size=\"22\">";
$output .= "</td></tr><tr><td>E-Mail address: *</td><td height=\"30\">";
$output .= "<input name=\"emailp$i\" type=\"text\" id=\"emailp\" size=\"22\"></td></tr><tr>";
$output .= "<td>Company:</td><td height=\"30\"><input name=\"companyp$i\" type=\"text\" id=\"companyp\" size=\"22\"></td></tr><tr>";
$output .= "<td>Postal Address: *</td><td height=\"30\"><input name=\"addressp$i\" type=\"text\" id=\"addressp\" size=\"22\"></td></tr><tr>";
$output .= "<td>Telephone: *</td><td height=\"30\"><input name=\"telephonep$i\" type=\"text\" id=\"telephonep\" size=\"22\"></td></tr><tr>";
$output .= "<td>Mobile Phone:</td><td height=\"30\"><input name=\"mphonep$i\" type=\"text\" id=\"mphonep\" size=\"22\"></td></tr><tr>";
$output .= "<td> </td><td> </td></tr></table><br>";
$i++;
$out++;
}
return $output;
?>