When I click on Submit button nothing happens neither it redirects nor the data in html form is posted to database.
Here is my code for date and time and location:
<?php
session_start();
$date1="";
$time1="";
$location="";
$db=mysqli_connect("localhost","root","","registration");
if(isset($_POST['submit'])) {
$date1 = mysqli_real_escape_string($db, $_POST['date1']);
$time1 = mysqli_real_escape_string($db, $_POST['time1']);
$location = mysqli_real_escape_string($db, $_POST['location']);
if (!empty($date)) {
$query = "INSERT INTO cars(date1,time1,location) VALUES('$date1', '$time1', '$location')";
mysqli_query($db, $query);
header('location:tariff.php');
}
}
?>
In this HTML sample the button name is Submit, when it is clicked the PHP is set to True and the code should be executed, but there are some errors.
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.form-inline{
text-align: center;
position: absolute;
top: 100px;
left: 500px;
}
.btn{
position: absolute;
top: auto;
left: 500px;
}
</style>
</head>
<body>
<div class="container"
<div class="panel panel-default"
<form class="form-inline" method="post" action="bookcar.php">
<div class="panel-body">
<p><label> Pick a date:</label><input class="form-control" type="date" name="date1" placeholder="Date"></p>
</div>
<div class="panel-body">
<p><label> Pick a Time:</label><input class="form-control" type="time" name="time1" placeholder="Time"></p>
</div>
<div class="panel-body">
<p><label> Pick a Location:</label><input class="form-control" type="text" name="location" placeholder="Location"></p>
</div>
<input type="submit" name="submit" value="submit" class="btn btn-lg btn-primary">
</form>
</div>
</div>
</body>
</html>