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
|
function securise($texte){
return htmlentities($texte, ENT_QUOTES);
}
if(isset($_POST["nom"]) and isset($_POST["prenom"]) and isset($_POST["email"]) and isset($_POST["sujet"]) and isset($_POST["message"])and !empty($_POST["nom"]) and !empty($_POST["email"]) and !empty($_POST["message"])){
if(!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)){
header('Location: contact.php?message=email&nom='.$_POST['nom'].'&prenom='.$_POST['prenom'].'&email='.$_POST['email'].'&telephone='.$_POST['telephone'].'&sujet='.$_POST['sujet'].'&demande='.$_POST['message']);
exit();
}
$nom = securise($_POST['nom']);
$prenom = securise($_POST['prenom']);
$email = securise($_POST['email']);
$sujet = securise($_POST['sujet']);
$message = securise(utf8_encode($_POST['demande']));
$headers = 'From:'.$prenom." ".$nom.' <'.$email.'>' . "\r\n" .
'Reply-To:'.$email. "\r\n" ;
mail('exemple@yahoo.fr', $sujet, $message, $headers);
header('Location: contact.php?message=ok');
.... |