title: PHP,MYSQL, How to create validation for date, which is we cannot input the date that already been input in database
body: <ul>
  <li>I'm using php and mysql database</li>
  <li>I'm doing my project of ballroom reservation</li>
  <li>I'm using datepicker at my booking reservation form</li>
  </ul>
  
  <p>I try to do/how to do?</p>
  
  <ul>
  <li>if else/validation; which is if the date that I already input in database will cannot be input same date at the second time.</li>
  </ul>
  
  <p>Can anyone help me how code it? </p>
  
  <pre><code>&lt;?php
  
  
  include 'connection.php';
  
  $date = $_POST['date'];
  $rand = rand ();
  session_start();
  $_SESSION['random']=$rand;
  $type = $_POST['typeofballroom'];
  $setup = $_POST['setup'];
  $name = $_POST['name'];
  $conNum = $_POST['contactnumber'];
  $email = $_POST['email'];
  $themes = $_POST['theme'];
  $menu = $_POST['menu'];
  $note = $_POST['notes'];
  
  
  
      $query = "SELECT * FROM ballroom_form WHERE date = '$date' ";
      $result = mysql_query($query);
  
  
  
  
      $person = mysql_fetch_array($result);
  
  
  
      if($date == $person['date']) {
      echo "unvalid refference number";
  
      }
  
  
      else
      {
      mysql_query ("INSERT INTO ballroom_form  (`ID`,`random_number`,`ballroom_type`,`set_up`,`date`,`name`,`contact_number`,`email`,`themes`,`menu`,`note`) VALUES (NULL,'$rand','$type','$setup','$date','$name','$conNum','$email','$themes','$menu','$note')") or die(mysql_error());
     echo "user has been added";
     header ('location: randomNum.php');
     }
  
  
  
  ?&gt;
  </code></pre>
  
  <p>it still when i input same date, it still proceed to ELSE. . . i have check all the form name, date name, database attribute, no typo no problem. </p>