biggieuk Posted December 3, 2007 Share Posted December 3, 2007 Hi all, Currently my form performs a validation function when the submit button is clicked. <input name="Submit" type="submit" id="Submit" value="Submit"> <form action="confirmation.php" method="post" enctype="multipart/form-data" name="booking" id="booking" onSubmit="return checkRadios()"> How can i also check with my MYSQL database to see if 'capacity' is the same as 'placesbooked' and display an error message to the user saying which sessions are fully booked and return to the form so they can change their selection? I am trying to do this so that people do not book themselves onto a session that is already filled. Thanks for help with this, Dan Quote Link to comment Share on other sites More sharing options...
trq Posted December 3, 2007 Share Posted December 3, 2007 Unless you want to delve into Ajax, you will need to check this by running a query once the form has been submitted. Quote Link to comment Share on other sites More sharing options...
biggieuk Posted December 3, 2007 Author Share Posted December 3, 2007 Im looking to explore Ajax within the next few weeks, for this i just need a quick working solution so that i can get it finished. Currently after pressing submit, a confirmation page is loaded displaying the details from the page before. I would need to have a page in between that could check the session capacity is not full before proceeding, otherwise the page is displayed showing the error and a back button so they can return to the booking form? Quote Link to comment Share on other sites More sharing options...
Bramme Posted December 3, 2007 Share Posted December 3, 2007 basic idea: confirmation.php if(isset($_POST['Submit'])) { $capacity = get the value, either from your form or your database; $placesbooked = get the value, either from your form or your database; if($capacity - $placesbooked < 0) { echo 'error!'; } else { //store the values from your form temporarily in a session (don't forget to start it!) $_SESSION['value'] = $_POST['value']; header("Location: confirm.php"); } confirm.php echo '<p>Your trip is succesfully booked</p>'; echo '<p>Your details were: <ul>'; echo '<li>'.$_SESSION['value'].'</li>'; echo '</ul>'; etc Quote Link to comment Share on other sites More sharing options...
biggieuk Posted December 6, 2007 Author Share Posted December 6, 2007 Thanks for your help, changed a few variables and its working fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.