|
Server IP : 82.197.83.136 / Your IP : 216.73.216.174 Web Server : LiteSpeed System : Linux us-bos-web1456.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u163988420 ( 163988420) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : ON Directory (0755) : /home/u163988420/domains/../domains/acmajmer.in/public_html/AACSITE/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'includes/db.php';
$success = false;
// Allow only POST requests
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// -----------------------------
// 1. Capture & sanitize input
// -----------------------------
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$subject = trim($_POST['subject'] ?? '');
$message = trim($_POST['message'] ?? '');
// -----------------------------
// 2. Basic validation
// -----------------------------
if (
$name !== '' &&
filter_var($email, FILTER_VALIDATE_EMAIL) &&
$subject !== '' &&
$message !== ''
) {
// -----------------------------
// 3. Insert safely into DB
// -----------------------------
$stmt = $conn->prepare(
"INSERT INTO contact_form (name, email, subject, message)
VALUES (?, ?, ?, ?)"
);
if ($stmt) {
$stmt->bind_param("ssss", $name, $email, $subject, $message);
if ($stmt->execute()) {
$success = true;
}
$stmt->close();
}
}
}
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Submission</title>
<!-- Bootstrap CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Success Modal -->
<div class="modal fade" id="successModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content text-center">
<div class="modal-header bg-success text-white">
<h5 class="modal-title w-100">Thank You!</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
Your message has been sent successfully.<br><br>
<a href="index.php" class="btn btn-outline-success">Back to Home</a>
</div>
</div>
</div>
</div>
<!-- Error Modal -->
<div class="modal fade" id="errorModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content text-center">
<div class="modal-header bg-danger text-white">
<h5 class="modal-title w-100">Submission Failed</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
Something went wrong while sending your message.<br><br>
<a href="index.php" class="btn btn-outline-danger">Try Again</a>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const modalId = "<?= $success ? 'successModal' : 'errorModal' ?>";
const modalEl = document.getElementById(modalId);
const modal = new bootstrap.Modal(modalEl);
modal.show();
modalEl.addEventListener('hidden.bs.modal', function () {
window.location.href = "index.php";
});
});
</script>
</body>
</html>