I am developing a web form in which users can book rooms and I want to prevent another booking taking place on the same date. How would I prevent someone else from booking a room that has already been booked.
as a example i am booking a room for 10 may to 12 may then i want that any user can not book that room for 10 may to 12 may or any date upto 12 may becouse it is already booked for 10 to 12.
and i have to text boxes in which start date and and end date are being entered i want to put a check here.
There are really a couple of parts to your question. The first part is how to prevent the user from choosing a room that has already been booked when they open up the page to choose the rooms they can book. If you know that a room has been booked, at this point, you would aim to let the user know that they can't book it by visually indicating that the room has been booked; perhaps by changing colours for that period. But you would also disable the buttons to save the booking if the user chooses that date.
The second part to your question is slightly more subtle, but is one that is often overlooked by people who forget that they are designing a multi-user system. What you are trying to prevent here is the user selecting a room that has been booked after the page has opened, or is being booked at the same time as they attempt to book that room. There's a simple trick to this - in your insert statement, use the date as part of the an insert test. You do this by using the ability to
INSERT based off a selection, and you test to see if the room has been booked for that date (the big hint here is that this is your select criteria). If you can't insert the record, then you know the room has been booked.
u would have created the table room !!!...insert the column status and keep the default value as false ...when an user books it change the value to true ....with this u can check and prevent the already booked room ....show the users only the rooms which are free ...
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)