Complicated PHP and SQL query/statement

I have created a booking system to book out employees time within our existing custom CMS system that is connected to our site.

I’m having difficulty in preventing double bookings.

Bookings are defined by staff name, day of week, start time, end time - n my SQL table these are all seperate column values.

My booking form is a single page and posts all of this data to the database at once. There is no ajax or background scripts checking availability against the table - I’d be interested in that route but I’m happy to just go with the user getting a message saying not available for the time being.

I’d appreciate any help with this.

When the form is submitted, why not simply check if an entry already exists for the person, on that day, and within that particular time frame? And if the database returns a result for these parameters, alert the user that the booking isn’t available?

Can indeed be done with an ajax call to get immediate feedback from the database.