Mini Shell
<?php
include('include/connection.php');
if (isset($_POST['enquiry'])) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
if (isset($_POST['product']) && $_POST['product'] != '') {
$product = $_POST['product'];
$price = $_POST['price'];
$sql = "INSERT INTO `book_query`(`product`, `name`, `email`, `phone`, `subject`, `message`) VALUES ('$product','$name','$email','$phone','$subject','$message')";
} else {
$sql = "INSERT INTO `contact`(`name`, `email`, `phone`, `subject`, `message`) VALUES ('$name','$email','$phone','$subject','$message')";
}
$res = mysqli_query($con, $sql);
if ($res) {
header("Location: " . $_SERVER['HTTP_REFERER']);
exit(); // It's a good practice to exit after redirection
} else {
echo "Error: " . mysqli_error($con); // Handle the error appropriately
}
}
if (isset($_POST['newsletter'])) {
$email = $_POST['email'];
$sql = "INSERT INTO `newsletter` (`email`) VALUES ('$email')";
$res = mysqli_query($con, $sql);
if ($res) {
header("Location: " . $_SERVER['HTTP_REFERER']);
exit(); // It's a good practice to exit after redirection
} else {
echo "Error: " . mysqli_error($con); // Handle the error appropriately
}
}