Probleme script envoie formulaire ?
jjsteing -
J'ai télécharger un site pré-conçu mon ma société, mais le formulaire de contact à l'air de ne pas fonctionner....
je vous passe mes codes :
traitement_email.php
<? $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: Infolex <infolex@ymail.com>\n"; $headers .= "Cc: $adresse\n"; $headers .= "Bcc: infolex@ymail.com\n"; $message = "Message de l'internaute :<br> $texte <br> Son nom et prénom : $nom $prenom <br> Son email : $email"; // On envoi l'email if ( mail($destinataire, $sujet, $message, $headers) ) echo "<div align=\"center\"> <a href=\"../index.html\"></a> </div>"; else echo "Un probleme est survenu lors de l'envoir de votre message !"; ?>
contact
<table width="610" height="99" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="486" bgcolor="#FFFFFF"><div align="center"><form id="formulaire" name="formulaire" action="../scripts/traitement_email.php" method="post" onSubmit="return verification()">
<table width="609">
<tr><td height="10"></td></tr>
<tr>
<td width="200" bgcolor="#D3E3EB"><p class="barretitre">Votre nom : </p></td><td width="397" bgcolor="#D3E3EB"><input name='nom' type='text' class='recherche' size="40"></td>
</tr>
<tr><td><p class="barretitre">Votre prénom : </p></td><td><input name='prenom' type='text' class='recherche' size="40"></td></tr>
<tr><td bgcolor="#D3E3EB"><p class="barretitre">Votre email :</p></td><td bgcolor="#D3E3EB"><input name='email' type='text' class='recherche'></td>
</tr>
<tr><td><p class="barretitre">Motif de <br />
votre message :</p></td><td><p class="barretitre">
<input name='sujet' type='radio' class="recherche" value='renseignements'>
Renseignements<br />
<input name='sujet' type='radio' class="recherche" value='bugs sur le site'>
Bugs sur le site<br />
<input name='sujet' type='radio' class="recherche" value='partenariat et publicité'>
Partenariat / publicité<br />
<input name='sujet' type='radio' class="recherche" value='autres'>
Autres ...</p></td></tr>
<tr><td bgcolor="#D3E3EB"><p class="barretitre">Votre message :</p></td><td bgcolor="#D3E3EB"><textarea name='texte' cols='35' rows='10' class='recherche'></textarea></td>
</tr>
<tr><td height="50"> </td><td bgcolor="#486778">
<div align="center"><a class="barretitre" onclick="javascript:if (verification()) {formulaire.submit();}" href="javascript:void(0);">ENVOYER</a><br />
</div></td>
</tr>
</table>
</form></div></td>
</tr>
</table>
Quelque chose ne va pas ou c'est la fatigue qui me prend ?
Merci d'avance !
Configuration: Windows Firefox 3.5.2
39 réponses
- 1
- 2
Le formulaire de contact d’un site préconçu ne transmet pas correctement les messages, avec des soucis autour du script traitement_email.php, de l’envoi via mail() et d’une éventuelle validation JavaScript. En pratique, les échanges ont insisté sur la nécessité d’un retour true/false dans la fonction de vérification JavaScript et sur la vérification de l’adresse destinataire côté PHP pour éviter les envois invalides. D'autres interactions évoquent l'erreur SMTP 550 A valid address is required et recommandent de corriger l'adresse du destinataire (ou d’ajuster le code d'envoi) pour que mail() renvoie true. En complément, certains conseils suggèrent d'intégrer des tests côté serveur et de vérifier que le formulaire et le script de traitement correspondent bien au chemin et au nom des champs.
-
if ( mail($destinataire, $sujet, $message, $headers) )
$sujet & $message ne sont pas définis non?
Faut peut être faire $sujet=$_POST['sujet']; et idem avec $message (en vérifiant qu'il sont bien définis). -
ce qui me donnerait comme code dans traitement-email.php :
<? $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: Infolex <infolex@ymail.com>\n"; $headers .= "Cc: $adresse\n"; $headers .= "Bcc: infolex@ymail.com\n"; $message = "Message de l'internaute :<br> $texte <br> Son nom et prénom : $nom $prenom <br> Son email : $email"; // On envoi l'email if ( mail($destinataire, $sujet=$_POST['sujet']; $message=$_POST['message']; $headers) ) echo "<div align=\"center\"> <a href=\"../index.html\"></a> </div>"; else echo "Un probleme est survenu lors de l'envoir de votre message !"; ?>
J'ai bien compris ou pas ? -
<?
if (isset($_POST['sujet']))
{
$sujet = $_POST['sujet'];
}
if (isset($_POST['texte']))
$texte = $_POST['texte'];
}
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: Infolex <infolex@ymail.com>\n";
$headers .= "Cc: $adresse\n";
$headers .= "Bcc: infolex@ymail.com\n";
$message = "Message de l'internaute :<br> $texte <br> Son nom et prénom : $nom $prenom <br> Son email : $email";
// On envoi l'email
if ( mail($destinataire, $sujet, $message, $headers) ) echo "<div align=\"center\">
<a href=\"../index.html\"></a>
</div>";
else echo "Un probleme est survenu lors de l'envoir de votre message !";
?> -
Bonjour,
quelque chose ne va pas ! OK
mais à quel niveau ?
cela se passe peut être au niveau des jascript que vous n'avez pas montré !
-
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -
ca ne marche toujours pas...
quand je clique sur le bouton "envoyer" rien ne se passe... voici le code du bouton "envoyer" :
<div align="center"><a class="barretitre" onclick="javascript:if (verification()) {formulaire.submit();}" href="javascript:void(0);">ENVOYER</a><br /> </div>
De quel code jascript ? -
voici le code entier de contact.html :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Infolex - Contact</title> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .Style1 { color: #FF0000; font-weight: bold; } .Style2 {color: #FFFFFF} .Style6 {font-size: 11px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; font-family: Verdana, Arial, Helvetica, sans-serif;} .Style7 { font-family: Oreos; font-size: 45px; } .Style8 { color: #000000; font-size: 12px; } --> </style> </head> <body> <div align="center"> <table width="900" height="69" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="302" background="images/header_logo.png"><div align="center"><span class="logoblanc Style7">Infolex</span><br /> <span class="titreblanc">Dépannage et cours d'informatique à domicile dans la région Grenobloise (38) </span></div></td> <td width="336"><img src="images/header_2.png" width="336" height="145" /></td> <td width="262"><div align="center"> <table width="299" height="122" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="35" background="images/recherche.png"><div align="center" class="Style2">L'informatique facile chez vous ! </div></td> </tr> <tr> <td height="110" valign="top" background="images/header_3.png"> </td> </tr> </table> </div></td> </tr> </table> <table width="900" height="42" border="0" cellpadding="0" cellspacing="0"> <tr> <td background="images/font_menu.png"><table width="670" height="42" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="134" background="images/menu_barre.png"><div align="center" class="titreblanc"><a href="index.html">Accueil</a></div></td> <td width="134" td background="images/menu_barre.png"><div align="center" class="titreblanc"><a href="services.html">Services</a></div></td> <td width="134" td background="images/menu_barre.png"><div align="center" class="titreblanc"><a href="tarifs.html">Tarifs</a></div></td> <td width="134" background="images/menu_barre.png" td><div align="center" class="titreblanc"><a href="nous_trouver.html">Nous trouver </a></div></td> <td width="134" td background="images/menu_barre.png"><div align="center" class="titreblanc"><a href="contact.html">Contact</a></div></td> </tr> </table></td> </tr> </table> <table width="900" height="33" border="0" cellpadding="0" cellspacing="0"> <tr> <td background="images/font_sousmenu.png"><div align="center"><span class="barretitre">Contactez nous 7j/7 24h/24 au 06.66.33.92.59. Il y aura toujours quelqu'un pour vous répondre ! </span></div></td> </tr> </table> <table width="900" height="417" border="0" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#D3E3EB"><div align="center"> <br /> <table width="880" height="103" border="0" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="234"><div align="center"> <table width="218" height="191" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="218" height="34" background="images/wind_haut.png"><div align="center"><span class="titreblanc">Trucs et Astuces </span></div></td> </tr> <tr> <td bgcolor="#FFFFFF" valign="top"><div align="center"> <table width="191" height="148" border="0" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="191" class="textegris"><img src="images/puce.png" width="14" height="14" /><a href="arret_xp.html"><font color="black">Réduction du temps d'arrêt...</font> </a><br /> <img src="images/puce.png" width="14" height="14" /><a href="swap.html"><font color="black">Nettoyer le fichier swap... </font></a><br /> <img src="images/puce.png" width="14" height="14" /><a href="conversion_fatntfs.html"><font color="black">Convertit FAT en NTFS</font></a><span class="Style6"><a href="conversion_fatntfs.html"><font color="black">...</font></a></span><br /> <img src="images/puce.png" width="14" height="14" /><a href="suppression_fichier.html"><font color="black">Supprimer un fichier...</font></a><br /> <img src="images/puce.png" width="14" height="14" /><a href="disquette_demarrage.html"><font color="black">Disquette de démarrage...</font></a><br /> <img src="images/puce.png" width="14" height="14" /><a href="bootscreen.html"><font color="black">Activer le boot screen...</font> </a><br /> <img src="images/puce.png" width="14" height="14" /><a href="fichier_recalcitrant.html"><font color="black">Fichier récalcitrant...</font></a><br /> <img src="images/puce.png" width="14" height="14" /><a href="adresseip.html"><font color="black">Connaître son IP...</font></a><br /> <img src="images/puce.png" width="14" height="14" /><a href="empecher_arret.html"><font color="black">Empêcher l'arrêt de windows...</font> </a><br /> <table width="191" height="23" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="right"> <table width="93" height="27" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="93" background="images/bouton_neutre.png"><div align="center" class="textegris"><a href="#">Lire la suite</a></div></td> </tr> </table> <br /> </div></td> </tr> </table></td> </tr> </table> </div></td> </tr> </table> </div> <br /> <div align="center"> <table width="218" height="191" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="34" background="images/wind_haut.png"><div align="center" class="titreblanc">Espace téléchargement </div></td> </tr> <tr> <td bgcolor="#FFFFFF" valign="top"><div align="center"> <table width="191" height="148" border="0" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="191" class="barretitre"><span class="textegris"><img src="images/puce.png" width="14" height="14" /><a href="open_office.html"><font color="black">Open Office 3.1.1 FR</font> </a><br /> <img src="images/puce.png" width="14" height="14" /><a href="gestion_prive.html"><font color="black">Gestion privé</font> </a><br /> <img src="images/puce.png" width="14" height="14" /><a href="pensebete.html"><font color="black">Pense-Bête</font></a><br /> <img src="images/puce.png" width="14" height="14" /><a href="linux.html"><font color="black">Mandriva Linux One</font> </a><br /> <img src="images/puce.png" width="14" height="14" /></span><span class="Style6"><a href="wxruby.html"><font color="black">Traducteur wxruby </font></a></span><span class="textegris"><br /> <img src="images/puce.png" width="14" height="14" /><a href="calculette.html"><font color="black">Calculatrice</font></a><br /> <img src="images/puce.png" width="14" height="14" /><br /> <img src="images/puce.png" width="14" height="14" /><br /> <img src="images/puce.png" width="14" height="14" /></span><br /> <br /> <div align="right"> <table width="93" height="27" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="93" background="images/bouton_neutre.png"><div align="center" class="textegris"><a href="#">Lire la suite</a></div></td> </tr> </table> <br /> </div></td> </tr> </table> </div></td> </tr> </table> </div></td> <td width="10"> </td> <td width="642" bgcolor="#FFFFFF"><div align="center"> <div align="center"><br /> <table width="610" height="27" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="486" bgcolor="#3E5A6C"><div align="center" class="titreblanc">Contactez-Nous !</div></td> </tr> </table> <table width="610" height="99" border="0" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="486" bgcolor="#FFFFFF"><div align="left"> <p class="textegris"><br /> Vous pouvez nous contacter par e-mail pour tout renseignement complémentaire. </p> <p class="textegris Style1">N'oubliez pas de nous laisser vos coordonées pour vous recontacter ! </p> <p class="textegris Style8">En cas de non fonctionnement du formulaire de contact, veuillez nous écrire à : contact@infolex.fr </p> </div></td> </tr> </table> <br /> <table width="610" height="99" border="0" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="486" bgcolor="#FFFFFF"><div align="center"><form id="formulaire" name="formulaire" action="../scripts/traitement_email.php" method="post" onSubmit="return verification()"> <table width="609"> <tr><td height="10"></td></tr> <tr> <td width="200" bgcolor="#D3E3EB"><p class="barretitre">Votre nom : </p></td><td width="397" bgcolor="#D3E3EB"><input name='nom' type='text' class='recherche' size="40"></td> </tr> <tr><td><p class="barretitre">Votre prénom : </p></td><td><input name='prenom' type='text' class='recherche' size="40"></td></tr> <tr><td bgcolor="#D3E3EB"><p class="barretitre">Votre email :</p></td><td bgcolor="#D3E3EB"><input name='email' type='text' class='recherche'></td> </tr> <tr><td><p class="barretitre">Motif de <br /> votre message :</p></td><td><p class="barretitre"> <input name='sujet' type='radio' class="recherche" value='renseignements'> Renseignements<br /> <input name='sujet' type='radio' class="recherche" value='bugs sur le site'> Bugs sur le site<br /> <input name='sujet' type='radio' class="recherche" value='partenariat et publicité'> Partenariat / publicité<br /> <input name='sujet' type='radio' class="recherche" value='autres'> Autres ...</p></td></tr> <tr><td bgcolor="#D3E3EB"><p class="barretitre">Votre message :</p></td><td bgcolor="#D3E3EB"><textarea name='texte' cols='35' rows='10' class='recherche'></textarea></td> </tr> <tr><td height="50"> </td><td bgcolor="#486778"> <div align="center"><a class="barretitre" onclick="javascript:if (verification()) {formulaire.submit();}" href="javascript:void(0);">ENVOYER</a><br /> </div></td> </tr> </table> </form></div></td> </tr> </table> <br /> </div> </div></td> </tr> </table> <br /> </div></td> </tr> </table>
Le code de traitement_email.php était entier.
Merci d'avance. -
re Bonjour,
le code n'est absolument pas complet.
vous faites appel à du javascript qui n'existe pas !
d'autre part vous pourriez aider vos "aideurs" en explicitant ce qui ne va pas.
nous devons chercher partout dnas des codes incomplets. -
si cela peut vous aider, j'ai un mini exemple (code) ici
http://jeanluc.richetin.free.fr/WebmasterTools/ -
giheller :vous me dites celui la.. mais je ne comprends pas ce qu'il ne va pas ?
ensuite vous me dites d'aider mes aideurs, je veux bien mais il faudrait déjà que je comprenne ce qu'il ne va pas... Quand je cliques sur le bouton "envoyer" rien ne se passe...
Quel code je devrais utiliser pour que cela fonctionne alors ?
Merci beaucoup et désolé de vous faire perdre votre temps. -
rien ne se passe car il appelle un javascript appelé verification() qui n'existe pas. que je n'ai pas vu dans la page html
-
si j'utilise un autre script j'ai peur que ca ne rende pas pareil... j'aurais souhaité garder cette présentation actuelle... si possible.
Merci beaucoup ! -
Et serait-il possible de le créer alors ce "vérification" ?
ou si en le supprimant ça fonctionne ?
Merci. -
attention svp :
<div align="center"><a class="barretitre" onclick="javascript:if (verification()) {formulaire.submit();}" href="#">ENVOYER</a><br />
ce code dit quand je clique sur envoyer exécuter le javascript appelé verification().
un seule question : où est-il ? (ce script verification()). -
vous pouvez supprimer son appel mais vous n'aurez pas le éventuelles vérifications de saisies.
bien sûr que vous pouvez écrire ce scrtip, ou alors aller le tetrouver là où vous avez trouver le code html.
à défaut regarder ce queje vous ai transmis -
La où j'ai pris ce script il n'y a rien d'autre.
Si je veux l'écrire je dois écrire quoi ?
Vraiment désolé et merci encore ! -
rajouter ça ici pour voir
<style type="text/css">
<!--
.Style1 {
color: #FF0000;
font-weight: bold;
}
.Style2 {color: #FFFFFF}
.Style6 {font-size: 11px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; font-family: Verdana, Arial, Helvetica, sans-serif;}
.Style7 { font-family: Oreos;
font-size: 45px;
}
.Style8 {
color: #000000;
font-size: 12px;
}
-->
</style>
<script language="JavaScript">
function verification(){
alert ("coucou");
return true;
}
</script>
</head> -
réponse au 16
ce script est alors peut être dans une librairie js .
de toute façon si il n'y est pas votre contact.htm ne peut focntionner.
voir donc ma réponse précédente -
Je le place où ce code exactement ?
Désolé mais en ce qui concerne la création de site je ne suis pas un expert....
Merci -
si vous regardez mon message n° 17 l'exemple est placé là où il doit être
-
Désolé je n'avais pas vu :s
Alors en ajoutant le script que vous m'avais donné, voici le message d'erreur que je reçois une fois le mail envoyé :
Warning: mail() [function.mail]: SMTP server response: 550 A valid address is required. in D:\www\infolex.fr\htdocs\scripts\traitement_email.php on line 13
Un probleme est survenu lors de l'envoir de votre message !
Et je n'ai donc reçu aucun e-mail... Faut-il modifier quelque chose dans le traitement_email.php maintenant ?
Merci !
- 1
- 2