<!DOCTYPE html>
<html>
<head>
   <title>Live Search using AJAX</title>
   <!-- Including jQuery is required. -->
   <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
   <!-- Including our scripting file. -->
   <script type="text/javascript" src="scripts6.js"></script>
   <script type="text/javascript" src="date.js"></script>
   <script type="text/javascript">
function SetDate()
{
var date = new Date();

var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();

if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;

var today = year + "-" + month + "-" + day;


document.getElementById('theDate').value = today;
}
</script>




   <!-- Including CSS file. -->
   <link rel="stylesheet" type="text/css" href="style.css">

   <link rel="stylesheet" href="main.css">


   <script type="text/javascript" src="search6.js"></script>
</head>
<body onload="SetDate();">

  <?php
  if ($_SERVER["REQUEST_METHOD"] == "GET") {

    require './db.php';

    $current_date = date("Y-m-d");
    // code...
    $sql = "INSERT INTO checking (firstname, lastname, CheckingDate, CheckingIn)
              VALUES ('" . mysqli_escape_string($con, $_GET['firstname']) . "', '"
                           . mysqli_escape_string($con, $_GET['lastname']) . "', '"
                          . mysqli_escape_string($con, $_GET['CheckingDate']) . "','"
                          . mysqli_escape_string($con, $_GET['CheckingIn']) . "')";

    $results = mysqli_query($con, $sql);

    if ($results === false) {
      echo mysqli_error($con);
    } else {

      $id = mysqli_insert_id($con);
       echo "Inserted recond with $id";
    }


  }

   ?>


<!-- Search box. -->
<div>

<div class="field">
<label for="search">Search</label>
   <input  type="text" id="search" placeholder="Search" />
   
   <hr>

   </div>
</div>
   
   

   <!-- Suggestions will be displayed in below div. -->
  <div class="field" id="display"></div>
   

   <form  method="GET">

      <div class="field">
     First Name:<input name="firstname" type="text" id="firstname" />
      </div>

       <div class="field">
      Last Name:<input name="lastname" type="text" id="lastname"  />
      </div>

      <div class="field">
      <input name="CheckingDate" type="date" id="theDate" placeholder="Search" />
      </div>

    <div class="field">
         <input name="CheckingIn" type="time" id="searchere" placeholder="Search" />
         </div>

   <div class="field"><button>CHECK IN</button></div>

   </form>
   

      




</body>
</html>
