|
Server IP : 2a02:4780:2b:1556:0:9c6:43c4:d / Your IP : 216.73.217.162 Web Server : LiteSpeed System : Linux us-bos-web1456.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64 User : u163988420 ( 163988420) PHP Version : 8.5.4 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, proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u163988420/domains/awskotra.in/../dnnindia.news/public_html/AACSITE/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include 'includes/db.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header("Location: contact.php");
exit;
}
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$mobile = trim($_POST['mobile'] ?? '');
$subject = trim($_POST['subject'] ?? '');
$message = trim($_POST['message'] ?? '');
$errors = [];
if (empty($name)) {
$errors[] = "Please enter your name.";
} elseif (strlen($name) > 100) {
$errors[] = "Name is too long.";
}
if (empty($email)) {
$errors[] = "Please enter your email.";
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = "Invalid email address.";
} elseif (strlen($email) > 150) {
$errors[] = "Email is too long.";
}
if (!empty($mobile)) {
if (!preg_match('/^[0-9+\-\s]{8,20}$/', $mobile)) {
$errors[] = "Invalid mobile number.";
}
}
if (empty($subject)) {
$errors[] = "Please enter subject.";
} elseif (strlen($subject) > 255) {
$errors[] = "Subject is too long.";
}
if (empty($message)) {
$errors[] = "Please enter message.";
} elseif (strlen($message) > 5000) {
$errors[] = "Message is too long.";
}
if (!empty($errors)) {
$_SESSION['error'] = implode('<br>', $errors);
header("Location: contact.php");
exit;
}
$stmt = mysqli_prepare(
$conn,
"INSERT INTO contactform
(
name,
email,
mobile,
subject,
message
)
VALUES
(?, ?, ?, ?, ?)"
);
if (!$stmt) {
$_SESSION['error'] = "Database error.";
header("Location: contact.php");
exit;
}
mysqli_stmt_bind_param(
$stmt,
"sssss",
$name,
$email,
$mobile,
$subject,
$message
);
$insert = mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
if ($insert) {
$_SESSION['success'] = true;
} else {
$_SESSION['error'] = "Something went wrong. Please try again.";
}
header("Location: contact.php");
exit;