Page 1 of 1
Re: online booking script
Posted: Sat Feb 07, 2015 8:16 am
by Celauran
I assume booking.processing.php submits to PayPal? You could put an intermediary "add to cart" step in between and let users choose when to process the payment.
Re: online booking script
Posted: Sat Feb 07, 2015 9:42 am
by Celauran
Could be something as simple as changing the form action to point to the intermediary page, storing their booking in session data, and presenting the user with the option to continue, which links back to the class selection page, or check out, which goes to the booking processing script.
Re: online booking script
Posted: Sat Feb 07, 2015 9:59 am
by Celauran
Since you're pointing the form action to that intermediary page, everything will be available to you via the $_POST superglobal. You can set up $_SESSION['classes'] (as an example), check that the currently selected $_POST data isn't already in that array, and store it into the $_SESSION['classes'] array, which can act as a simple cart of sorts. Once they choose to check out, you grab all of the items out of that array, pass them into your PayPal form, and process payment for all items at once.
Re: online booking script
Posted: Sat Feb 07, 2015 10:04 am
by Celauran
It's certainly enough to get you started.
Re: online booking script
Posted: Sat Feb 07, 2015 11:16 am
by Celauran
What data is being overwritten where? Where are you trying to store the selected bookings prior to processing? Also, copying that whole page was probably not a great idea. There's a lot of logic that's going to end up being duplicated, quite possibly to bad effect. I'd recommend keep the responsibilities of the two scripts entirely separate; one saves to session, one processes payments, or something along those lines.
Re: online booking script
Posted: Sat Feb 07, 2015 11:31 am
by Celauran
You need to start your sessions before any output is sent to the browser.
Re: online booking script
Posted: Sat Feb 07, 2015 2:20 pm
by Celauran
That's hard to say without knowing how your application is structured.
Re: online booking script
Posted: Sat Feb 07, 2015 3:27 pm
by Celauran
Because you're saving them to the same variable. Why not use an array of values instead?
Re: online booking script
Posted: Sat Feb 07, 2015 3:34 pm
by Celauran
Could be as simple as this
Of course that performs no validation and I don't recommend copying that directly into your code, but just gives an idea of how you might want to approach it.
Re: online booking script
Posted: Sat Feb 07, 2015 3:41 pm
by Celauran
An array is just a list. [0] represents the first item in the list. [1] is the second item, and so forth. That's pretty much all there is to it. Rather than store a string value in the array as your example did, I'm suggesting you store the entirety of the form data. The principle remains the same, though.