
<?php
// We need to use sessions, so you should always start sessions using the below code.
//session_start();
//If the user is not logged in redirect to the login page...
//if (!isset($_SESSION['frontdesk'])) {
//	header('Location: ../../frontpage/index.html');
//	exit;
//}
//?>


<!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"] == "POST") {

    require 'database.php';

    $current_date = date("Y-m-d");
    // code...
    $sql = "INSERT INTO thites (member, ThithesAmount, ThithesDate)
              VALUES ('" . mysqli_escape_string($con, $_POST['member']) . "', '"
                          . mysqli_escape_string($con, $_POST['amount']) . "','"
                          . mysqli_escape_string($con, $_POST['Date']) . "')";

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

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

      $id = mysqli_insert_id($con);
       echo "thithes enter successfully with $id";
    }


  }

   ?>


<!-- Search box. -->
<form  method="post">

<div class="field">
<label for="search">Search Member to enter tithe for</label>
   <input name="member" type="text" id="search" placeholder="Search" />
   </div>
 <!-- Suggestions will be displayed in below div. -->
  <div class="field" id="display"></div>
   <div class="field">
      <label for="">Date</label><input type="date" id="theDate" name="Date" placeholder="Search" />
      </div> 
    <div class="field">
        <label for="">Enter Amount: </label><input type="number" id="enternumber" name="amount" style="width:30%" placeholder="$">$</span></div>


   <div class="field">
   <label for=""></label> 
   <input type="submit"></div>

   </form>

     




</body>
</html>
