-
Notifications
You must be signed in to change notification settings - Fork 0
/
thanks.php
108 lines (85 loc) · 2.96 KB
/
thanks.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Thanks for your message!</title>
<meta name="description" content="description" />
<meta name="author" content="author" />
<meta name="keywords" content="keywords" />
<!-- <link rel="stylesheet" href="./stylesheet.css" type="text/css" /> -->
<meta charset="UTF-8" />
</head>
<body>
<?php
// Form validation
$firstname = $lastname = $email = $phone = $messageTopic = $message = '';
$firstnameErr = $lastnameErr = $emailErr = $phoneErr = $messageTopicErr = $messageErr = '';
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
};
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['user_firstname'])) {
$firstnameErr = 'First name is required';
} else {
$firstname = test_input($_POST['user_firstname']);
}
if (empty($_POST['user_lastname'])) {
$lastnameErr = 'Last name is required';
} else {
$lastname = test_input($_POST['user_lastname']);
}
if (empty($_POST['user_mail'])) {
$emailErr = 'E-mail is required';
} else {
$email = test_input($_POST['user_mail']);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST['user_phone'])) {
$phoneErr = 'Phone number is required';
} else {
$phone = test_input($_POST['user_phone']);
}
if (empty($_POST['message-topic'])) {
$messageTopicErr = 'Choosing a topic is required';
} else {
$messageTopic = test_input($_POST['message-topic']);
}
if (empty($_POST['user_message'])) {
$messageErr = 'Message is required';
} else {
$message = test_input($_POST['user_message']);
}
}
?>
<!-- MESSAGES : thank you or error -->
<?php
if (isset($firstnameErr)) {
echo '<br/>' . $firstnameErr;
}
if (isset($lastnameErr)) {
echo '<br/>' . $lastnameErr;
}
if (isset($emailErr)) {
echo '<br/>' . $emailErr;
}
if (isset($phoneErr)) {
echo '<br/>' . $phoneErr;
}
if (isset($messageTopicErr)) {
echo '<br/>' . $messageTopicErr;
}
if (isset($messageErr)) {
echo '<br/>' . $messageErr;
}
if ($firstnameErr == null && $lastnameErr == null && $emailErr == null && $phoneErr == null && $messageTopicErr == null && $messageErr == null) {
echo '<div>' . '<p>' . 'Merci ' . $_POST['user_firstname'] . ' ' . $_POST['user_lastname'] . ' de nous avoir contacté à propos de "' . $_POST['message-topic'] . '".' . '</p>' . '</div>' . PHP_EOL . '<div>' . '<p>' . 'Un de nos conseiller vous contactera soit à l’adresse ' . $_POST['user_mail'] . ' ou par téléphone au ' . $_POST['user_phone'] . ' dans les plus brefs délais pour traiter votre demande :' . '</p>' . '</div>' . PHP_EOL . '<div>' . '<p>' . $_POST['user_message'] . '</p>' . '</div>';
}
?>
</body>
</html>