Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL); // Active toute les erreurs ( a ne pas foutre en prod )
- $list_email = array(
- 1 => "commercial@#.com",
- 2 => "rh@#.com",
- 3 => "helpdesk@#.com",
- 4 => "webagency@#.com",
- 5 => "sse@#.com",
- 6 => "sruse@#.com",
- 7 => "alassane@#.com"
- );
- $your_email = intval($_POST['emailaddress']); // Email qui recevront les messages
- if(!empty($your_email) && intval($your_email)){
- if(!isset($list_email[$your_email]){
- exit("Vous n'avez pas choisi de destinataire");
- }
- }
- if ($_SERVER['REQUEST_METHOD'] != 'POST') exit; // Quit if it is not a form post
- // quick way clean up incoming fields
- foreach($_POST as $key => $value) $_POST[$key] = urldecode(trim($value));
- // get form data into shorter variables
- // each $_POST variable is named based on the form field's id value
- $destinataire = intval($_POST['emailaddress']);
- $name = $_POST['sender_name'];
- $email = $_POST['sender_email'];
- $message = $_POST['message'];
- $code = $_POST['code'];
- $errors = array(); // array of errors
- // basic validation
- if ($destinataire == 0) {
- $errors[] = "- Le champ \"Destinataire\" n'est pas renseigné, merci de rectifier.";
- }
- if ($name == '') {
- $errors[] = "- Le champ \"Nom/Prénom\" n'est pas renseigné, celui-ci doit avoir un minimum de 3 caractères alphabétique a-zA-Z";
- }elseif(is_int($name)){
- $errors[] = "- Le champ \"Nom/Prenom\" ne doit comporter que des caractères alphabétique a-zA-Z";
- }
- /**
- * REGEX POUR LA VALIDATION DE L'EMAIL CLIENT
- * ([^\D]{0,})(\w+[_\-\.]+\w+)@([a-z0-9]+)\.(\b[a-zA-Z]{2,6}\b)
- * babacar.tall@gmail.comhlk
- * babacar.tallgmail.com
- * babacar.tall_2@gmail.info
- * babacar.tall_2@gmail.fr
- babacar_tall-34@gm9-ail.com
- babacar.tall-@gmail.com
- babacar.tall@-gmail.com
- babacar.tall@gmail-.com
- -babacar.tall-@gmail.com
- babacar.tall@gmail.-com
- 2babacar.tall@gmail.com
- 2435babacar.tall@gmail.com
- */
- if (empty($email)) {
- $errors[] = "- Merci de renseigner le champ \"Email\" avec une adresse correctement remplis et valide";
- }
- if ($message == '' or strlen($message) < 10) {
- $errors[] = "- Le champ \"Message\" n'est pas renseigné, celui-ci doit avoir un minimum de 10 caractères";
- }
- if (sizeof($errors) == 0) {
- // only check the code if there are no other errors
- require_once '../securimage/securimage.php';
- $img = new Securimage;
- if ($img->check($code) == false) {
- $errors[] = "Merci de renseigner le champ Captcha \"Anti-spam correctement\"";
- } // if the code checked is correct, it is destroyed to prevent re-use
- }
- if (sizeof($errors) > 0) {
- // if errors, send the error message
- $str = implode("\n", $errors);
- exit("Il y a une erreur avec votre soumission!\n Assurez-vous d'avoir renseigné tous les champs, et réessayer.\n\n" . $str);
- }
- $time = date('r');
- $body = <<<EOD
- Bonjour!
- Un message vous a été envoyé à partir de $name à $time.
- Voici le message:<br /><br />
- $message
- EOD;
- // send email
- mail($your_email, "Contact Form Sent", $body, "From: $your_email\r\nReply-To: $email\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nMIME-Version: 1.0");
- exit('OK'); // send success indicator
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement