<?php
session_start();
include('dbcon.php');

if(isset($_POST['save_inquiry'])){
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $message = $_POST['message'];

    $stmt = $conn->prepare("INSERT INTO tbl_inquiry (name, phone, email, address, message) VALUES (?, ?, ?, ?, ?)");
    $stmt->bind_param("sssss", $name, $phone, $email, $address, $message);

    if($stmt->execute()){
        $_SESSION['status'] = "Inquiry Added Successfully!";
        header("Location: view-inquiry.php");
        exit();
    } else {
        $_SESSION['status'] = "Failed to Add Inquiry!";
        header("Location: add-inquiry.php");
        exit();
    }
} else {
    $_SESSION['status'] = "Access Denied";
    header("Location: add-inquiry.php");
    exit();
}
?>
