<!DOCTYPE HTML>
<html>
<head>
	<title>HATSU HAIR</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<link rel="stylesheet" href="assets/css/main.css" />
</head>
<header id="header" class="alt">
	<div class=><img width="1200" height="180" src="images/jjjj12.jpg" alt="" /></div><br>

	<h1><strong><a href="index.php" class="button special"><font >Sign out</font></a></strong></h1><br>
  <nav id="nav">


  </nav>

</header>

<a href="#menu" class="navPanelToggle"><span class="fa fa-bars"></span></a>
  <section id="one" class="wrapper style1">
		<div class="container 75%">
			<div class="row 200%">
				<div class="6u 12u$(medium)">
					<center>

				          <center>
				          <header class="major">
				            <h2>Booking Today</h2>

				          <div class="image rounded"><img width="100" src="images/pic08.jpg" alt="" /></div><br>
									<?php
									@ini_set('display_errors', '0');
									$name = $_POST["name"];
									$gender = $_POST["gender"];
									$selection = $_POST["selection"];
									$time = $_POST["time"];
									$date = $_POST["date"];
									$phone = $_POST["phone"];
									if($name and $gender and $selection and $date and $phone){
										$stringX = "Hello ".$name.". you selected ".$selection." at ".$time." ".$date;
										echo "<h4><font color=\"green\">$stringX</font></h4>";

									}

									 ?>
									<div class="major">
										<FORM>

									<?php
										include "config.php";
										$dbname = "web";

										// Create connection
										$conn = mysqli_connect($servername, $username, $password);
										// Check connection
										if (!$conn) {
												die("Connection failed: " . mysqli_connect_error());
										}else{
											echo " ";
										}

										mysqli_select_db($conn, $dbname);
										$sql = "SELECT * FROM `booking`";

										$result = mysqli_query($conn, $sql);

										if (mysqli_num_rows($result) > 0) {
												// output data of each row
												echo "<table>";
												while($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
														@ini_set('display_errors', '0');

														echo "<tr>";
														echo "<td>"."<font color=\"blue\">Name : </font>" . $row["name"]."  ". $row["make"]." ". $row["geder"]. " Time : ". $row["time"]. $row["date"]."</td>";
														echo "</tr>";
												};
												echo "</table>";

										}
										else {
												echo "0 results";
										}

										mysqli_close($conn);
									?>

									</FORM>
									</div>
				          <p>hatsu hair Salon & Barber</p>
				          </header>
					</header>
				</center>
				</div>



				<form name="form1" method="post" action="booking_dbs.php" > <br> ;
				<table border="1" style="width: 300px">
				<tbody>
					<tr>
						<td><h2>Booking</h2></td>
					</tr>
				<tr><td> &nbsp;Name</td><td><input name="name" type="text" id="name"></td></tr>
				<tr><td> &nbsp;Gender</td><td>
					<select class="" name="gender">
						<option value=""></option>
						<option value="male">male</option>
						<option value="female">female</option>
					</select></td></tr>
					<tr><td> &nbsp;Selection</td><td>
						<select class="" name="selection">
							<option value=""></option>
							<option value="Cut">Cut</option>
							<option value="Perm">Perm</option>
							<option value="Stretching">Stretching</option>
							<option value="Color">Color</option>
						</select>
						<tr><td> &nbsp;Time</td><td>
							<select class="" name="time">
								<option value="00.00 PM"></option>
								<option value="01.00 PM">01.00 PM</option>
								<option value="01.30 PM">01.30 PM</option>
								<option value="02.00 PM">02.00 PM</option>
								<option value="02.30 PM">02.30 PM</option>
								<option value="03.00 PM">03.00 PM</option>
								<option value="03.30 PM">03.30 PM</option>
								<option value="04.00 PM">04.00 PM</option>
								<option value="04.30 PM">04.30 PM</option>
								<option value="05.00 PM">05.00 PM</option>
								<option value="05.30 PM">05.30 PM</option>
								<option value="06.00 PM">06.00 PM</option>
								<option value="06.30 PM">06.30 PM</option>
								<option value="07.00 PM">07.00 PM</option>
								<option value="07.30 PM">07.30 PM</option>
								<option value="08.00 PM">08.00 PM</option>
							</select>
							<tr><td> &nbsp;Date (dd/mm/yyyy)</td><td><input name="date" type="text" id="date" size="45"></td></tr>
							<tr><td> &nbsp;Phone</td><td><input name="phone" type="text" id="phone"></td></tr>
							<tr>
								<td>

									<?php
									$servername = "localhost";
									$username = "aaaa";
									$password = "aaaa";
									$dbname = "web";

									$name = $_POST["name"];
									$gender = $_POST["gender"];
									$selection = $_POST["selection"];
									$selection = $_POST["selection"];
									$time = $_POST["time"];
									$date = $_POST["date"];
									$phone = $_POST["phone"];
									$checkDT=array();
									$check=array("00.00 PM");
									$checks=array();
									$DT = $date.$time;

										if($name and $gender and $selection and $date and $phone){

									  // Create connection
									  $conn = mysqli_connect($servername, $username, $password);
									  // Check connection
									  if (!$conn) {
									      die("Connection failed: " . mysqli_connect_error());
									  }else{
									    echo " ";
									  }
									  mysqli_select_db($conn, $dbname);
									  $sql = "SELECT * FROM `booking`";
									  $result = mysqli_query($conn, $sql);

									  if (mysqli_num_rows($result) > 0) {
									      // output data of each row

									      while($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {

									        array_push($check, $row["time"]);
													array_push($checks, $row["date"].$row["time"]);

									};

									  }
									  else {
									      echo "0 results";
									  }
									  mysqli_close($conn);
											foreach ($checks as $key => $value) {
										    array_push($checkDT, $value);
										  };

									  if (in_array($DT, $checkDT)) {
											echo "<font color=\"red\">Unsuccessful! <br> Please specify the time not to match the existing booking today. </font>";

										}
									  else {


												$conn = mysqli_connect($servername, $username, $password);
										    // Check connection
										    if (!$conn) {
										        die("Connection failed: " . mysqli_connect_error());
										    }else{
										      echo " ";
										    }
										    mysqli_select_db($conn, $dbname);
										    $sql = "SELECT * FROM `booking`";
										    $result = mysqli_query($conn, $sql);



										    $sql = "INSERT INTO `booking` (`id`, `name`, `geder`, `make`, `time`, `date`, `phone`)
										    VALUES (NULL, '$name', '$gender', '$selection', '$time', '$date', '$phone')";

										    if ($conn->query($sql) === TRUE) {
										        echo "<font color=\"green\">Created successfully</font>";

										    } else {
										        echo "Error: " . $sql . "<br>" . $conn->error;
										    }

										    $conn->close();

										  };





									}
									else {
										 echo "<font color=\"blue\">Please fill in the information!</font>";
									}


									?>


								</td>
							</tr>

								</td>
							</tr>
					</td></tr>
			</tbody>
				</table><br>
				<input type="submit" name="Submit" value="SAVE">

				</form>

				</div>

      </div>
    </div>
  </section>

				</div>
			</div>
		</div>
	</section>

<!-- Two -->

<section id="three" class="wrapper style1">
	<div class="container">
		<header class="major special">
			<h2>Choose your hair style</h2>
			<p>To build confidence for you</p>
		</header>
		<div class="feature-grid">
			<div class="feature">
				<div class="image rounded"><img src="images/pic09.jpg" alt="" /></div>
				<div class="content">
					<header>
						<h4>Curling men</h4>
						<p>Curling men</p>
					</header>
					<p>How To Get Curly Hair For Men
If you have straight hair, you may be wondering how to get curly hair for men. Fortunately.</p>
				</div>
			</div>

			<div class="feature">
				<div class="image rounded"><img src="images/pic10.jpg" alt="" /></div>
				<div class="content">
					<header>
						<h4>Women hair color</h4>
						<p>Women hair color</p>
					</header>
					<p>The new year is the best time to switch up your look — after all, new year, new you, right? If you're looking for some hair color inspiration, take a cue from these gorgeous blonde, brunette, red, and multi-tone hair hues that are going to be huge in 2019.</p>
				</div>
			</div>
			<div class="feature">
				<div class="image rounded"><img src="images/pic11.jpg" alt="" /></div>
				<div class="content">
					<header>
						<h4>Male haircut</h4>
						<p>Male haircut</p>
					</header>
					<p>Short haircuts for men are the go-to haircut styles for most guys. There is something very satisfying about going to the barber to get your hair all cleaned up and looking fresh.</p>
				</div>
			</div>
			<div class="feature">
				<div class="image rounded"><img src="images/pic12.jpg" alt="" /></div>
				<div class="content">
					<header>
						<h4>Curling women</h4>
						<p>Curling women</p>
					</header>
					<p>curls are the easiest way to glam up your look. If you weren't blessed with 'em naturally, there are some super simple ways to get those waves on your own.</p>
				</div>
			</div>
		</div>
	</div>
</section>

<!-- Four -->


<!-- Footer -->
<div class=><img width="1200" height="200" src="images/jjj0j1.jpg" alt="" /></div><br>
<footer id="footer">
<div class="container">
	<ul class="icons">
		<li><a href="https://www.facebook.com/hatsuhairubon/" class="icon fa-facebook"></a></li>


		</ul>

</footer>

<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>

</body>
</html>
