r/PHPhelp • u/MonsieurKyro • Oct 09 '17
Checking for availability between dates
So basically I am to make a reservation system for a resort. I have already made a database: https://imgur.com/f9aLyFZ. I really need to know how to check if dates are available when making a reservation.
So far I did this: $sql = "SELECT * FROM room_type_tbl
INNER JOIN room_tbl ON room_type_tbl.room_type_id=room_tbl.room_type_id
WHERE room_type_tbl.room_capacity='$roomcap' && ('$datein'>booking_tbl.checkin_date && '$dateout'<booking_tbl.checkoutdate)
";
if ($conn->query($sql) === TRUE) {
//echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}It's not working and I'm about to go mad. Please help me.
8
Upvotes
3
u/pablojohns Oct 09 '17 edited Oct 10 '17
Side note: please tell me you’re not storing the full card number and expiration in this database in plaintext. The fact that the field is for an integer is very concerning.
Please consider using a 3rd party payment processor as this is asking for MAJOR trouble, not just for the client but for your reputation as well. Cards should be run once through a processor for an authorization, and then kept securely on file WITH THE PROCESSOR, not in a database with the full card number, expiration, and customer billing info.