Jump to content

[SOLVED] Check database for fully booked session before submitting


biggieuk

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
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.