Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alexhackney's avatar

Form Validation help

I have a client that wants a booking system built in to their website. I can build it out, but how would you approach this?

They want to be able to book in 4 hour windows. 0800 - 1200 | 1200-1600 | 1600-2000

When a client books an appointment, the soonest they can book is the first 4 hour windows after 16 hours from the current time. Plus they want to limit two bookings per window.

How would I show this to the user and validate that it matches those restrictions?

Meaning, how could I populate a bootstrap form to show the list of available appointments and how would I save this data in the database.

Would it be better to list out all the upcoming appointments that are available for the next 2 weeks or would it be better just to have them pick a date and a window and then kick it back out if that is not available.

Then for the database side, would I just have a table of appointments and then these columns?

id | date | start_time | end_time | name | street_address | city | state | zip | phone

Or is it better to have a table with dates and appointment window ids and then I could change that later? Just not real sure how to approach this...

Thanks!

0 likes
3 replies
skliche's avatar

@alexhackney Nah, you're not and it's a nice problem to think about.

Would it be better to list out all the upcoming appointments that are available for the next 2 weeks or would it be better just to have them pick a date and a window and then kick it back out if that is not available.

If you look at booking forms for flight, hotels, ... you have similar constraints and options. You can have the user pick a date and specify something like +/- 1, 2, 3, ... days and return available slots. But it's frustrating if you enter the date you would like and everything is taken. So why not combine those approaches and start out with a list of the upcoming available slots plus have them choose their own date window.

Depending on what is booked and what the usage pattern is you would choose what upcoming slots you offer. If booking that stuff at short notice is preferred the next 2 weeks would be fine. If people like to book in advance choose some typical upcoming season.

Did anyone bother to ask the users what they would like to see first?

Snapey's avatar

Just make sure that two bookings per time band is not a limitation or assumption in the code. If the business is successful, there is a good chance they will come back and want 3/4 bookings per window.

alexhackney's avatar

@skliche We did not ask the users because they currently do not have anyone booking like this. The owners just gave me these constraints.

@Snapey How could I do this to make it flexible like that?

I'm still confused on where I'm setting up the windows. What if they want to change the windows later to 2 hour windows. How can I do this so that they could go in to a backend and change the appointment options?

Please or to participate in this conversation.