Formulaire contact

Webal Messages postés 99 Date d'inscription   Statut Membre Dernière intervention   -  
 Utilisateur anonyme -
Bonjour,

quelqu'un pourrait m'indiquer ou se trouve mon erreur, car il est impossible pour moi de recevoir de courriel via ma page contact

merci encore voici mon code php

<?php
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$mail = $_POST['mail'];
$comments = $_POST['commentaire'];
$subject = "DEMANDE DE RENSEIGNEMENT";
$to = "mon courriel";
$msg = "
<html>
<body>
<table>
<tr>
<td>Prenom :</td>
<td>$prenom</td>
</tr>
<tr>
<td>Nom :</td>
<td>$nom</td>
</tr>
<tr>
<td>Email :</td>
<td>$mail</td>
</tr>
<tr>
<td>Commentaires :</td>
<td>$comments</td>
</tr>
</table>

</body>
</html>";

$headers = "From: $mail";
$headers .= 'MIME-Version: JACYSTYLE' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to,$subject, $msg, $headers);

header('Location: index.html');
?>





et voici ma page html

<table width="432" border="0" align="right">
<tr>
<td> Si vous avez des questions n'hésitez surtout pas !!!</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><form id="form1" name="form1" method="post" action="envoi.php">
<table width="525" border="0">
<tr>
<td width="143" height="35px;" align="right" style="padding-right:8px;">Nom :</td>
<td width="287"><input type text= "text" size= "25" maxlength= "50" name="nom"style="background-color:#3366ff"/></td>
</tr>
<tr>
<td align="right" style="padding-right:8px;" height="35px;">Prénom :</td>
<td><input type text= "text" size= "25" maxlength= "50" name="prenom"style="background-color:#3366ff"/></td>
<td width="56"> </td>
</tr>
<tr>
<td align="right" style="padding-right:8px;" height="35px;">Courriel :</td>
<td><input type text= "text" size= "45" maxlength= "75" name="mail"style="background-color:#3366ff"/></td>
<td> </td>
</tr>
<tr>
<td align="right" style="padding-right:8px;" height="35px;">Commentaires :</td>
<td><textarea name="commentaire" cols="34" rows="4"style="background-color:#3366ff"></textarea></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input name="btnSubmit" type="submit" value="Envoyer" onclick="check()"/></td>
<td> </td>
</tr>
</table>
<p> </p>
<p>Vous pouvez aussi nous joindre par courriel au : jacystyle@live.ca<br />
ou encore par téléphone au : 514.924.0429 </p>
</form></td>
</tr>
</table>



Il est important de VIVRE SES RÊVES & non pas de rêver sa vie !!!

1 réponse

Utilisateur anonyme
 
Bonjour,

Ne faut-il pas aussi un "\r\n" a la fin de "From:" ?

Tu peux ajouter:
.= "Content-Transfer-Encoding: 8bit\r\n" [pour les accents]
.= "MIME-version: 1.0\r\n" [ et non JACYSTYLE lol ]

Ensuite voila surement ce qui te manque:
ini_set( 'sendmail_from' , "$_POST['nom'] <$_POST['mail']>" ) ;
ini_set( 'SMTP' , 'adresse smtp du serveur mail' ) ;

Ensuite tu pourrais lancer la fonction dans un if ( mail() ) {} else {}
tu saura au moins si cela fonctionne et cela peut servir a afficher un message de reussite/erreur a celui qui envoi.

Ensuite si la fonction plante l'erreur doit s'afficher donc n'oublie pas de mettre error_reporting( -1 ) ; (en developpement seulement bien sur).

Ensuite pas de "onclick" sur un form mais un "onsubmit" c'est plus propre et fonctionne aussi si on appuie sur la touche "entree"

Pour finir n'oublie pas un exit; ou die(); apres ton header afin d'arreter le script et le parcours du code.

Voila en esperant t'avoir aider. Si tu as encore besoin n'hesite pas et si ton post est résolu n'oublie pas de le mettre comme tel ;-)

Au cas ou:
http://www.siteduzero.com/tutoriel-3-35146-e-mail-envoyer-un-e-mail-en-php.html

+++ Spangenhelm +++
0