1. Create a trigger which verifies the dates. However, only from MySQL 5.5 were SIGNAL's introduces which allows us to raise and exception. Prior to that version the process was to insert into a table that contain a duplicate value causing a duplicate entry exception to be raised.
2. A stored function which performs the checks and either inserts or not depending on the checks and returns either a 1 or 0 for success or failure.
3. In your PHP code perform the checks before calling the INSERT statement.