<?php
session_start();
?>
<?php
include 'dbconnect.php';
?>
<!DOCTYPE HTML>  
<html>
<head>
    <meta charset="UTF-8">
    <title>Welcome</title>
    <link rel="stylesheet" href="
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
    <style type="text/css">
        body{ font: 14px sans-serif; text-align: center; }
    </style>
</head>
<body>
    <div class="page-header">
        <h1>BOOK A VENUE</h1>
    </div>
<body>  
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<?php
// define variables and set to empty values
$personsErr = 0;
$timeErr = "";
$persons = 0;
$time = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (empty($_POST["estimated number of people"])) {
      $personsErr = "An estimated number is required.";
    }
    if (empty($_POST["timeslot"])) {
        $timeErr = "A selection is required.";
      }
$link = mysqli_connect("localhost", "root", "", "venue booking");
$sql = "INSERT INTO timeslot (time ,persons) VALUES ('$time','$persons')";
mysqli_query($link, $sql);
 mysqli_close($link);
}    
function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
?>
<h2>Please enter the </h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  
  Estimated number of people: <input type="number" name="estimated number of people" value="<?php echo $persons;?>">
  <br>
  <span class="error">* <?php echo $personsErr;?></span>
  <br><br>
 
  Time Slot:
  <br>
  <span class="error">* <?php echo $timeErr;?></span>
  <br><br>
  <input type="radio" name="timeslot" <?php if (isset($time) && $time=="10am - 12pm") echo "checked";?> value="10am - 12pm">10am - 12pm
  <br><br>
  <input type="radio" name="timeslot" <?php if (isset($time) && $time=="12pm - 2pm") echo "checked";?> value="12pm - 2pm">12pm - 2pm
  <br><br>
  <input type="radio" name="timeslot" <?php if (isset($time) && $time=="2pm - 4pm") echo "checked";?> value="2pm - 4pm">2pm - 4pm  
  <br><br>
  <input type="submit" name="submit" value="Submit">   
  <br>
  <a href=welcome-user.php class="btn btn">Go back</a>
</form>
</body>
</html>