Bonjour,
je suis tres novice, j'ai recuperé un template que j'ai modifié a ma sauce mais les messages envoyés via le formulaire de contact n'arrivent pas a ma boite. J'ai bien "message has been sent". J'ai testé la redirection de l'hebergeur depuis un compte gmail, elle fonctionne.
le site en construction est www.aizeavoyages.com
Voici les differents codes, merci beaucoup de votre aide.
HTML
le fichier php: contact_me.php
et enfin le JS:
je suis tres novice, j'ai recuperé un template que j'ai modifié a ma sauce mais les messages envoyés via le formulaire de contact n'arrivent pas a ma boite. J'ai bien "message has been sent". J'ai testé la redirection de l'hebergeur depuis un compte gmail, elle fonctionne.
le site en construction est www.aizeavoyages.com
Voici les differents codes, merci beaucoup de votre aide.
HTML
<!-- Contact Section -->
<div id="contact">
<div class="container">
<div class="col-md-8">
<div class="row">
<div class="section-title">
<h2>Contact</h2>
<p>Pour toutes informations, veuillez nous envoyer un message,
nous répondons dans la journée la plupart du temps ou sous 24
heures .</p>
</div>
<form name="sentMessage" id="contactForm" novalidate="">
<div class="row">
<div class="col-md-6">
<div class="form-group"> <input id="name" class="form-control"
placeholder="Name"
required="required"
type="text">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group"> <input id="email" class="form-control"
placeholder="Email"
required="required"
type="email">
<p class="help-block text-danger"></p>
</div>
</div>
</div>
<div class="form-group"> <textarea name="message" id="message" class="form-control" rows="4" placeholder="Message"
required=""></textarea>
<p class="help-block text-danger"></p>
</div>
<div id="success"></div>
<button type="submit" class="btn btn-custom btn-lg">Send Message</button>
</form>
</div>
</div>
le fichier php: contact_me.php
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'info@aizeavoyages.com' - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: noreply@aizeavoyages.com"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
et enfin le JS:
$(function() {
$("input,textarea").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {
// additional error messages or events
},
submitSuccess: function($form, event) {
event.preventDefault(); // prevent default submit behaviour
// get values from FORM
var name = $("input#name").val();
var email = $("input#email").val();
var message = $("textarea#message").val();
var firstName = name; // For Success/Failure Message
// Check for white space in name for Success/Fail message
if (firstName.indexOf(' ') >= 0) {
firstName = name.split(' ').slice(0, -1).join(' ');
}
$.ajax({
url: "././mail/contact_me.php",
type: "POST",
data: {
name: name,
email: email,
message: message
},
cache: false,
success: function() {
// Success message
$('#success').html("<div class='alert alert-success'>");
$('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
$('#success > .alert-success')
.append("<strong>Your message has been sent. </strong>");
$('#success > .alert-success')
.append('</div>');
//clear all fields
$('#contactForm').trigger("reset");
},
error: function() {
// Fail message
$('#success').html("<div class='alert alert-danger'>");
$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
$('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
$('#success > .alert-danger').append('</div>');
//clear all fields
$('#contactForm').trigger("reset");
},
})
},
filter: function() {
return $(this).is(":visible");
},
});
$("a[data-toggle=\"tab\"]").click(function(e) {
e.preventDefault();
$(this).tab("show");
});
});
/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {
$('#success').html('');
});