merci,
J'ai placé le script au sommet de ma page.
<?php
// Define some constants
define( "RECIPIENT_NAME", "Savoie Rando" );
define( "RECIPIENT_EMAIL", "contact@toto.fr" );
define( "EMAIL_SUBJECT", "Nouvelle Demande" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$telephone = isset( $_POST['telephone'] ) ? preg_replace( "/[^\ \-0-9]/", "", $_POST['telephone'] ) : "";
$participants = isset( $_POST['participants'] ) ? preg_replace( "/[^\ \-0-9]/", "", $_POST['participants'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
$message .= "\n\nNom: $senderName\n\n";
$message .= "\n\nTelephone: $telephone\n\n";
$message .= "\n\nNombre de participants: $participants\n\n";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body class="contact">
<?php if ( $success ) echo "<p>Merci nous vous répondrons dans les plus brefs délais .</p>" ?>
<?php if ( !$success ) echo "<p>Erreur lors de l'envoi. Recommencez.</p>" ?>
</body>
</html>
<?php
}
?>
j'édite le message car j'avais oublié la fonction ajax
// Submit the form via Ajax
function submitForm() {
var contactForm = $(this);
// Are all the fields filled in?
if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
// No; display a warning message and return to the form
$('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
contactForm.fadeOut().delay(messageDelay).fadeIn();
} else {
// Yes; submit the form to the PHP script via Ajax
$('#sendingMessage').fadeIn();
contactForm.fadeOut();
$.ajax( {
url: contactForm.attr( 'action' ) + "?ajax=true",
type: contactForm.attr( 'method' ),
data: contactForm.serialize(),
success: submitFinished
} );
}
// Prevent the default form submission occurring
return false;
}
// Handle the Ajax response
function submitFinished( response ) {
response = $.trim( response );
$('#sendingMessage').fadeOut();
if ( response == "success" ) {
// Form submitted successfully:
// 1. Display the success message
// 2. Clear the form fields
// 3. Fade the content back in
$('#successMessage').fadeIn().delay(messageDelay).fadeOut();
$('#senderName').val( "" );
$('#senderEmail').val( "" );
$('#message').val( "" );
$('#content').delay(messageDelay+500).fadeTo( 'slow', 1 );
} else {
// Form submission failed: Display the failure message,
// then redisplay the form
$('#failureMessage').fadeIn().delay(messageDelay).fadeOut();
$('#contactForm').delay(messageDelay+500).fadeIn();
}
}
Dans dreamweaver, il y a aussi ces options lorsque l'on enregistre la page,pourraient elle servir à quelque chose ? (j'ai essayé la première solution en cochant: include unicode signature (BOM)
C (Canonical Decomposition, followed by Canonical Composition)
D (Canonical Decomposition)
KC (Compatibility Decomposition, followed by Canonical Composition)
KD (Compatibility Decomposition)
a cocher: include unicode signature (BOM)
Modifié par truitas (14 Dec 2012 - 11:21)