diff options
Diffstat (limited to 'contact-post.php')
-rw-r--r-- | contact-post.php | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/contact-post.php b/contact-post.php new file mode 100644 index 0000000..fc7f5f3 --- /dev/null +++ b/contact-post.php | |||
@@ -0,0 +1,94 @@ | |||
1 | <?php | ||
2 | session_start(); | ||
3 | $_SESSION['adresse'] = $_POST['adresse']; | ||
4 | $_SESSION['contenu'] = $_POST['contenu']; | ||
5 | |||
6 | if (isset($_POST['captcha'])) | ||
7 | { | ||
8 | if ($_POST['captcha'] == 5) | ||
9 | { | ||
10 | if (isset ($_POST['adresse']) AND isset ($_POST['contenu'])) | ||
11 | { | ||
12 | if ($_POST['adresse'] != '' AND $_POST['contenu'] != '') | ||
13 | { | ||
14 | // convertir les caractères spéciaux en leur équivalent HTML | ||
15 | $adresse = $_POST['adresse']; | ||
16 | $contenu = $_POST['contenu']; | ||
17 | |||
18 | if (filter_var($adresse, FILTER_VALIDATE_EMAIL)) | ||
19 | { | ||
20 | $destinataire = 'blog@ordipolo.fr'; | ||
21 | $sujet = 'message de ' . htmlspecialchars($adresse) . ' envoyé depuis le blog'; | ||
22 | |||
23 | // On filtre les serveurs qui rencontrent des bogues. | ||
24 | /*if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $destinataire)) | ||
25 | { | ||
26 | $passage_ligne = "\r\n"; | ||
27 | } | ||
28 | else | ||
29 | { | ||
30 | $passage_ligne = "\n"; | ||
31 | }*/ | ||
32 | $passage_ligne = "\r\n"; | ||
33 | |||
34 | $contenu = htmlspecialchars($contenu); | ||
35 | |||
36 | echo $passage_ligne; | ||
37 | |||
38 | // En-tête | ||
39 | //$boundary = "-----=" . md5(rand()); | ||
40 | |||
41 | $header = 'From: siteweb <' . $adresse . '>' . $passage_ligne; // expéditeur | ||
42 | $header .= 'Reply-to: ' . $adresse . ' <' . $adresse . '>' . $passage_ligne; // réponse | ||
43 | $header .= 'Return-path : ' . $adresse . ' <' . $adresse . '>' . $passage_ligne; // retour en cas d'erreur | ||
44 | $header .= 'MIME-Version: 1.0' . $passage_ligne; | ||
45 | $header .= 'Content-type: text/plain; charset=utf-8 boundary=\"' . $boundary . '\"' . $passage_ligne; | ||
46 | |||
47 | // message | ||
48 | //$message = $passage_ligne."--".$boundary.$passage_ligne; | ||
49 | //$message .= "Content-Transfer-Encoding: 8bit".$passage_ligne; | ||
50 | $message .= $passage_ligne . $contenu . $passage_ligne; | ||
51 | //$message .= $passage_ligne."--".$boundary.$passage_ligne; | ||
52 | |||
53 | echo $destinataire; | ||
54 | echo "<br/>"; | ||
55 | echo $sujet; | ||
56 | echo "<br/>"; | ||
57 | echo $message; | ||
58 | echo "<br/>"; | ||
59 | echo $header; | ||
60 | |||
61 | // Envoi | ||
62 | mail($destinataire, $sujet, $message, $header); | ||
63 | |||
64 | // envoi réussi, on peut nettoyer | ||
65 | unset ($_SESSION['adresse']); | ||
66 | unset ($_SESSION['contenu']); | ||
67 | |||
68 | header('Location: contact.php?erreur=0'); | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | header('Location: contact.php?erreur=1'); | ||
73 | } | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | header('Location: contact.php?erreur=1'); | ||
78 | } | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | header('Location: contact.php?erreur=1'); | ||
83 | } | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | header('Location: contact.php?erreur=2'); | ||
88 | } | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | header('Location: contact.php?erreur=2'); | ||
93 | } | ||
94 | ?> | ||