File "submit_form.php"
Full path: /home/quiczmwg/lightspringdigitals.com/../../quiczmwg/solixproperties.org/submit_form.php
File size: 1.22 KiB (1249 bytes)
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8
Download Open Edit Advanced Edit Back
<?php
// Include database connection file
include_once("../_db.php");
// Initialize variables
$status = $message = '';
// Check if the form is submitted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Retrieve form data
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$purpose = $_POST['purpose'];
// Insert into database
$insertQuery = "INSERT INTO contact (fullname, email, phone, subject, purpose) VALUES (?, ?, ?, ?, ?)";
$insertStmt = $conn->prepare($insertQuery);
// Check if prepare() was successful
if ($insertStmt) {
$insertStmt->bind_param("sssss", $fullname, $email, $phone, $subject, $purpose);
if ($insertStmt->execute()) {
$status = 'success';
$message = 'Message sent successfully';
} else {
$status = 'error';
$message = 'Failed to execute insert query: ' . $insertStmt->error;
}
} else {
$status = 'error';
$message = 'Failed to prepare SQL statement: ' . $conn->error;
}
// Display status message
echo '<div style="color: ' . ($status === 'success' ? 'green' : 'red') . ';">' . $message . '</div>';
}
?>