Ca ne fonctionne pas non plus lol
<button type="submit" value="validate-message" name="validate-message">Envoyer</button>
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 28 29 30 31 32 33 34 35 36 37 38
| <?php
if(isset($_POST['validate-message']) {
if(!empty($_POST['form3_prenom']) && !empty($_POST['form3_nom']) && !empty($_POST['form3_email']) && !empty($_POST['form3_message'])) {
$form3_telephone = !empty(trim($_POST['form3_telephone'])) ? htmlspecialchars($_POST['form3_telephone']) : 'Non renseigné';
$to = 'XXXXXX@gmail.com'; // Mon adresse réelle
$subject = 'Contact depuis le site';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From:' .$_POST['form3_prenom']. " " .$_POST['form3_nom']. "\r\n";
$headers .= 'Reply-To:'.$_POST['form3_email']. "\r\n";
$message = '<html><body>';
$message .= '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>';
$message .= '<table>';
$message .= '<tr><td colspan="2"><p>MESSAGE</p></td></tr>';
$message .= '<tr><td>Prenom :</td><td>'.htmlspecialchars($_POST['form3_prenom']).'</td></tr>';
$message .= '<tr><td>Nom :</td><td>'.htmlspecialchars($_POST['form3_nom']).'</td></tr>';
$message .= '<tr><td>Email :</td><td>'.htmlspecialchars($_POST['form3_email']).'</td></tr>';
$message .= '<tr><td>Telephone :</td><td>'.$form3_telephone.'</td></tr>';
$message .= '<tr><td>Message :</td<td>'.htmlspecialchars($_POST['form3_message']).'</td></tr>';
$message .= '</table>';
$message .= '</body></html>';
if(mail($to, $subject, $message, $headers)){
echo "Formulaire envoyé";
} else {
echo "Formulaire non envoyé";
}
} else {
echo "Vous n'avez pas rempli tous les champs";
}
}
?> |
Partager