<?php
include('session_admin.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Query Search Up Page</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
  @import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css);
  * {
      box-sizing: border-box;
  }

  .header {
      border: 1px solid #DE584F;
      padding: 15px;
  }

  .social a {
      text-align: center;
      width: 52px;
      height: 52px;
      float: left;
      background: #fff;
      border: 1px solid #ccc;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15), inset 0 0 50px rgba(0, 0, 0, 0.1);
      border-radius: 24px;
      margin: 0 10px 10px 0;
      padding: 6px;
      color: #000;
  }

  .twitter a:hover {
      background: #00acee;
      color: #fff;
  }

  .instagram a:hover {
      background: #3f729b;
      color: #fff;
  }

  .facebook a:hover {
      background: #3b5998;
      color: #fff;
  }

  .header {
      border: 1px solid #DE584F;
      padding: 15px;
  }

  .row::after {
      content: "";
      clear: both;
      display: table;
  }


  /* Paralax animation*/

  .parallax {
      height: 100vh;
      background-image: url(../Web-App/logo4-01.svg);
      background-attachment: fixed;
      background-repeat: no-repeat;
      background-position: center center;
  }

  .row::after {
      content: "";
      clear: both;
      display: table;
  }

  ul {
      list-style-type: none;
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #333;
  }

  li {
      float: left;
  }

  li a {
      display: block;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
  }

  li a:hover {
      background-color: #111;
  }

  [class*="col-"] {
      float: left;
      padding: 15px;
  }


  /* This is allocating layout spaces for how the website is going to be allocated the spaces for different contencts. */

  .col-1 {
      width: 8.33%;
  }

  .col-2 {
      width: 16.66%;
  }

  .col-3 {
      width: 0;
  }

  .col-4 {
      width: 33.33%;
  }

  .col-5 {
      width: 41.66%;
  }

  .col-6 {
      width: 50%;
  }

  .col-7 {
      width: 58.33%;
  }

  .col-8 {
      width: 66.66%;
  }

  .col-9 {
      width: 100%;
      text-align: center;
  }

  .col-10 {
      width: 83.33%;
  }

  .col-11 {
      width: 91.66%;
  }

  .col-12 {
      width: 100%;
  }

  ul {
      list-style-type: none;
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #333;
  }

  li {
      float: left;
  }

  li a {
      display: block;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
  }

  li a:hover:not(.active) {
      background-color: #111;
  }

  .active {
      background-color: #DE584F;
  }

  @import url(https://fonts.googleapis.com/css?family=Roboto:400,300,600,400italic);
  * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      -webkit-font-smoothing: antialiased;
      -moz-font-smoothing: antialiased;
      -o-font-smoothing: antialiased;
      font-smoothing: antialiased;
      text-rendering: optimizeLegibility;
  }

  body {
      font-family: "Roboto", Helvetica, Arial, sans-serif;
      font-weight: 100;
      font-size: 20px;
      line-height: 40px;
      color: #777;
      height: 200vh;
      background-image: linear-gradient(to top, gray, white 40%);
  }

  .container {
      max-width: 600px;
      margin: 0 auto;
      position: relative;
  }

  #search input[type="departure"],
  #search input[type="arrival"],
  #search input[type="class"],
  #search input[type="date"],
  #search input[type="date"],
  #search input[type="filters"],
  #search button[type="submit"] {
      font: 400 12px/16px "Roboto", Helvetica, Arial, sans-serif;
  }

  #search {
      background: #F9F9F9;
      padding: 25px;
      margin: 15px 0;
      box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
  }

  #search h3 {
      display: block;
      font-size: 30px;
      font-weight: 300;
      margin-bottom: 10px;
  }

  #search h4 {
      margin: 5px 0 15px;
      display: block;
      font-size: 13px;
      font-weight: 400;
  }

  fieldset {
      border: medium none !important;
      margin: 0 0 10px;
      min-width: 100%;
      padding: 0;
      width: 100%;
  }

  #search input[type="departure"],
  #search input[type="arrival"],
  #search input[type="class"],
  #search input[type="date"],
  #search input[type="date"],
  #search input[type="filters"] {
      width: 100%;
      border: 1px solid #ccc;
      background: #FFF;
      margin: 0 0 5px;
      padding: 10px;
  }

  #search input[type="departure"]:hover,
  #search input[type="arrival"]:hover,
  #search input[type="class"],
  #search input[type="date"]:hover,
  #search input[type="date"]:hover,
  #search input[type="filters"]:hover {
      -webkit-transition: border-color 0.3s ease-in-out;
      -moz-transition: border-color 0.3s ease-in-out;
      transition: border-color 0.3s ease-in-out;
      border: 1px solid #aaa;
  }

  #search button[type="submit"] {
    cursor: pointer;
    width: 100%;
    border: none;
    background: #4CAF50;
    color: #FFF;
    margin: 0 0 5px;
    padding: 10px;
    font-size: 20px;
  }

  #search button[type="submit"]:hover {
    background: #43A047;
    -webkit-transition: background 0.3s ease-in-out;
    -moz-transition: background 0.3s ease-in-out;
    transition: background-color 0.3s ease-in-out;
  }

  #search button[type="submit"]:active {
    box-shadow: inset 0 1px rgba(0, 0, 0, 0.5);
  }

  #search input:focus,
  #search textarea:focus {
      outline: 0;
      border: 1px solid #aaa;
  }

  ::-webkit-input-placeholder {
      color: #888;
  }

  :-moz-placeholder {
      color: #888;
  }

  ::-moz-placeholder {
      color: #888;
  }

  :-ms-input-placeholder {
      color: #888;
  }

  [class*="button7"] {
      background-color: #DE584F;
  }

  .button7 {
      font-weight: 700;
      color: white;
      text-decoration: none;
      padding: .8em 2em calc(.8em + 3px);
      border-radius: 3px;
      background: #DE584F(64, 199, 129);
      box-shadow: 0 -3px #DE584F(53, 167, 110) inset;
      transition: 0.2s;
  }

  .button7:hover {
      background: #DE584F(206, 211, 208);
  }

  .button7:active {
      background: rgb(33, 147, 90);
      box-shadow: 0 3px rgb(33, 147, 90) inset;
  }
  </style>
</head>

<body>
  <?php
  $Subject = "";

  if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $Subject = test_input($_POST["Subject"]);
  }

  function test_input($data) {
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
  }

  ?>

  <div class="col-9">
      <h1>Reservation Webpage</h1>
  </div>

  <div class="col-12">
    <ul>
      <li><a href="index1.php">Home</a></li>
      <li><a href="contact.php">Contact</a></li>
      <li><a href="index1.php">About</a></li>
      <li><a href="loginform_for_admin_2.php">Admin place</a></li>
      <li><a class="active" href="query_2.php">Customer queries</a></li>
      <li><a href="admin_delete_record.php">Deleting record</a></li>
      <li><a href="logout_admin.php">Logout</a></li>
    </ul>
  </div>

  <div class="container">
    <fieldset>
      <form id="search" method="post" action="<?php $PHP_SELF?>">
        <legend>
          <h1>Searching customer queries</h1>
        </legend>
        <legend>Please select your subject:</legend>
        <select name="Subject">
          <option value="Reporting problems in the website">Reporting problems in the website</option>
          <option value="Questions, queries and problems using the website">Questions, queries and problems using the website</option>
          <option value="Request">Request in the website</option>
          <option value="Cancelling a flight">Cancelling a flight</option>
        </select>
        <input type="hidden" name="flight_search" value="yes" />
        <input type="submit" name="submit" class="button7" value="Search" />
      </form>
    </fieldset>

    <?php
    //This is only displayed if the user submitted the form
    if (isset($_POST['flight_search'])){
      echo "<h2>Results</h2><p>";
      //If the user did not enter a search term, they receive an error
      if ($_POST['Subject'] == ""){
        echo "<p>Please select a subject";
        exit;
      }

      // Otherwise we connect to the database
      $con = mysqli_connect(localhost,root, root, Airline_Booking, 8889);

      // Check connection
      if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

      if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $Subject = ($_POST["Subject"]);
      }

      $data = mysqli_query($con, "SELECT * FROM Contact WHERE Subject = '$Subject'");

      //And display the results

      while($row = mysqli_fetch_array( $data )) {
        echo "$row[1]". " " ."$row[2]". " " . "$row[3]". " " . "$row[4]". " ";
        echo "<br>";
      }

      //This counts the number or results. If there aren't any, it gives the user a "no match" message
      $anymatches=mysqli_num_rows($data);
      if ($anymatches == 0) {
        echo "Sorry, but we can not find an entry to match your query<br><br>";
      }

      //And reminds the user what they searched for
      echo "<b>Searched For:</b> " . "$find";
    }

    //break;

    if (isset($_GET['Flight_Id#'])) {
      $Flight_Id = $_GET['Flight_Id'];
      echo $Flight_Id;
    }
    ?>
  </div>

  <!-- social media block -->
  <div class="social twitter">
    <a href="#" target="_blank"><i class="fa fa-twitter fa-2x"></i></a>
  </div>
  <div class="social instagram">
    <a href="#" target="_blank"><i class="fa fa-instagram fa-2x"></i></a>
  </div>
  <div class="social facebook">
    <a href="#" target="_blank"><i class="fa fa-facebook fa-2x"></i></a>
  </div>
</body>
</html>