Using/storing server-side data on the client side
Right now, you have two separate AJAX calls: one to determine if a day has bookings, and one to determine whether a specific time slot can be booked.

I would suggest one of two things:


Send a request only once that returns all booking data for the specified date.
Send only a validation request upon clicking Book; don't bother checking if a date has bookings.


Option 1 is the ideal approach, since it minimises requests. However, if for some reason you don't want a user to know when you're booked, you'll need to go with option 2. Whichever option you go with, you should provide feedback on its success (or failure) after submission, in case somebody else booked it sometime between validation and submission.



If you're adamant about continuing with your approach, then instead of using 0 and 1, consider using a salted hash involving the date. For illustrative purposes, I'm only using one round (since this type of thing doesn't need to be cryptographically secure).

define("BOOKING_DATE_SALT", "asprin111")
$flag = md5($clicked_date . ($db-&gt;num_rows() ? "yes" : "no") . BOOKING_DATE_SALT);
...


Of course, you won't want to repeat this code in check-slot-availability.php so it would probably belong better as a function in some shared library.