title: How to find out if the dates fall under the date range that existed in database
body: <p>I've tried different method to validate if the date fall on the existed date itself and also the date range in the database however it doesn't work at all. The coding will ignore the query and let user to book the asset successfully. </p>
  
  <p>This is the image of my database:</p>
  
  <p><img src="https://i.stack.imgur.com/cQw5j.jpg" alt="dates"></p>
  
  <pre><code>&lt;?php 
  session_start();
  include("dbFunctions.php");
  
  $message = "";
  
  
  if (isset($_POST['end_date'])) {
  //retrieve form data
  $endd1 = $_POST['end_date'];
  $startd1 = $_POST['start_date'];
  $assetID = $_POST['asset_id'];
  
  //check if start date and end date range entered exists within database record
  $query = "SELECT * FROM booking WHERE booking.asset_id = '$assetID' AND ('$startd1' BETWEEN booking.start_date AND booking.due_date) AND ('$endd1' BETWEEN booking.start_date AND booking.due_date) " ;
  
  $result = mysqli_query($link, $query) or die(mysqli_error($link));
  
  if (mysqli_num_rows($result) == 1) {
      $exists = true;
  } else {
      $exists = false;
  }
  } else {
      $msg .= 'Sorry, Please enter another date.';
      $msg .= '&lt;br/&gt;';
      $msg .= '&lt;a href="addBooking.php"&gt;Please try again.&lt;/a&gt;';
  } 
  </code></pre>