This is my first post, so here goes...
Q. How can I build an online booking application using a MySQL transaction which remains open over several pages? I have a feeling that the answer might be in good ol' $_SESSION, but haven't found any examples of this nature. Maybe the best way is not to use transactions at all? Any thoughts?
Example - Booking a place (or places) on an instructional course with limited availability
Page 1
Number of available places is shown.
Customer fills in necessary fields on form and chooses number of places to book.
Pressing 'submit' takes us to page 2.
Page 2
BEGIN transaction.
Check details from page 1 and INSERT them into relevant 'customers', 'bookings' tables.
The availability visibile to other customers now becomes the availability shown in the 'availability' table less the number of places booked. (READ UNCOMMITED)
Customer checks his details and presses 'confirm' to proceed to payment page.
Page 3 (Off-site)
Third party payment page.
Allows customer to pay for the place(s) booked on page 1.
After payment, directs customer to page 4.
Page 4a
Checks for a successful payment and decrements availability by the number of places booked.
COMMIT transaction.
Page 4b
Checks for unsuccesful payment, ROLLBACK and terminates transaction.
If the customer navigates away and remains away for a certain amount of time, then the transaction terminates.
I hope someone out there has come across this before!
Cheers.