-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.php
More file actions
30 lines (26 loc) · 1.13 KB
/
message.php
File metadata and controls
30 lines (26 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
include 'include/db.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Sécurisation des champs
$name = htmlspecialchars(trim($_POST['name']));
$email = htmlspecialchars(trim($_POST['email']));
$subject = htmlspecialchars(trim($_POST['subject']));
$message = htmlspecialchars(trim($_POST['message']));
// Vérification simple
if (!empty($name) && !empty($email) && !empty($message)) {
$stmt = $conn->prepare("INSERT INTO contact_messages (name, email, message) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $name, $email, $message);
if ($stmt->execute()) {
echo "<script>alert('Message envoyé avec succès. Merci de nous avoir contactés !'); window.location.href='index.php';</script>";
} else {
echo "<script>alert('Une erreur est survenue : " . $stmt->error . "'); window.history.back();</script>";
}
$stmt->close();
} else {
echo "<script>alert('Veuillez remplir tous les champs obligatoires.'); window.history.back();</script>";
}
} else {
header("Location: index.php");
exit;
}
?>