Hi I cannot get the below query to work in order to insert the session data into the database, Could anyone please tell me what is wrong with it or what I can do to fix it? Thanks in advance.
<?php
session_start();
if (isset($_POST['sub'])) {
$host='localhost';
$user='root';
$pass='';
$db='theatre_booking';
$con=mysqli_connect($host,$user,$pass,$db);
$row = $_POST['row'];
$_SESSION["row"]=$row;
$zone = $_POST['zone'];
$_SESSION["zone"]=$zone;
$quantity = $_POST['numberOfTickets'];
$_SESSION["numberOfTickets"]=$quantity;
$sql="INSERT INTO booking(PerfDate, PerfTime, Name, Email, RowNumber)
VALUES
'{$_SESSION['date']}',
'{$_SESSION['time']}',
'{$_SESSION['name']}',
'{$_SESSION['email']}',
'{$_SESSION['row']}')";
if ($con->query($sql) === TRUE) {
echo "Booking successful";
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
}
?>