Récupération de données d'un formulaire php

Fermé
ju - 10 juin 2009 à 12:53
 ju - 15 juin 2009 à 09:39
Bonjour,

Je suis débutant et je suis en train de faire un formulaire sur dreamweaver. Je recoit bien le formulaire sur mon adresse mail mais mes champs ne sont pas dans le mail ce qui me donne donc

Société : pas d'info
Nom : pas d'info ...

Je ne comprend pas d'ou vient le probleme

Voici mon code si quelqu'un peut m'aider ?

<?php

extract($_POST);
$to = "contact@vanilia-events.com";
$subject = "Nouvelle demande";
$message = "Une nouvelle demande est arrivee \n
Societe: $societe \n
Email: $email \n
Nom: $nom \n
Prenom: $prénom \n
Service: $service \n
Budget: $Budget \n
Nombre de participants: $Participants \n
Arrivee: $Arrivée \n
Depart: $départ \n
Information: $Information \n";
$entete= "Form: $nom \n Reply-to: $email";
mail($to, $subject, $message, $headers);
echo "Votre demande a bien été envoyée. Vanilia vous remercie pour cette demande, un chef de projet reviendra vers vous dans les prochaines 24H."
?>

Merci

Ju
A voir également:

9 réponses

Mimiste Messages postés 1149 Date d'inscription samedi 17 mai 2008 Statut Membre Dernière intervention 6 mars 2016 206
10 juin 2009 à 13:55
Salut

Tu est sur que les noms des champs et tes variables correspondent bien ? Par exemple pour $societe t'a bien un champ qui s'appel "societe" ? Les majuscules rentrent en compte

Sinon il est vraiment deconseiller d'utiliser la fonction extract sur des donnees ecrite par un utilisateur, question de securité
0
Merci de ta réponse

Oui j'ai vérrifié cela correspond. J'ai aussi enlevé la fonction extract pour eviter les soucis mais la mon formulaire ne part plus du tout et un message d'erreure apparaît:

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /web/vaniliaevents/www/6-nouvelle-demande/nouvelle-demande.php on line 13

mon code est le suivant:

<?php

$to = "contact@monsite.com";
$subject = "Nouvelle demande";
$message = "Une nouvelle demande est arrivee \n
Societe: $_POST["Société"] \n
Email: $_POST["email"] \n
Nom: $_POST["nom"] \n
Prenom: $_POST["Prénom"] \n
Service: $_POST["Service"] \n
Budget: $_POST["Budget" \n
Nombre de participants: $_POST["Participants"] \n
Arrivee: $_POST["Arrivée"] \n
Depart: $_POST["départ"] \n
Information: $_POST["Information"] \n";
$entete= "Form: $nom \n Reply-to: $email";
mail($to, $subject, $message, $headers);
echo "Votre demande a bien été envoyée."
?>

Etant novice je gualère vraiment quand même...

ju
0
Mimiste Messages postés 1149 Date d'inscription samedi 17 mai 2008 Statut Membre Dernière intervention 6 mars 2016 206
10 juin 2009 à 16:34
ha oui ça ne peut pas fonctionner de cette maniere tu oublie la concatenation des chaines il faut que tu le fasse de cette maniere pour toute tes variables :

$message = "Une nouvelle demande est arrivee \n
Societe: ".$_POST["Société"]." \n

etc....
0
Merci pour ta réponse,

Je viens de corriger le code en effet je recois le formulaire maintenant mais malheureusement mes champs restent déséspérement vide. Je ne comprend pas pourquoi j'ai verrifié l'écriture logiquement cela devrait marcher.

Je reviens donc à mon problème initiale même en effacant la fonction extract. Je ne vois pas d'ou peut venir le problème. Voilà mon code source du formulaire

<div id="titrecentre">Nouvelle demande</div>
<div id="centre">
<div class="F_Mid Style1" id="PressRelease_Introduction">
<fieldset>
<legend></legend>
<table width="572" height="353" border="0">
<tr>
<td width="183" align="left" valign="top"><div align="center" class="Style3 Style3">
<div align="left">
<p class="Style10">Société :</p>
</div>

</div></td>
<td width="379" align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="société" class="Style3 Style10" id="société">
<p>
<label for="Société"></label>
<input type="text" name="Société" id="Société" accesskey="s" tabindex="10" />
</p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style3">
<div align="left">
<p class="Style10">Email :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form2" class="Style3 Style10" id="form2">
<p><span id="sprytextfield1">
<label for="email"></label>
<input type="text" name="email" id="email" accesskey="e" tabindex="20" />
<span class="textfieldRequiredMsg Style9">Adresse email complète.</span><span class="Style9 textfieldInvalidFormatMsg">Adresse email complète</span></span> </p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Nom :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form3" class="Style3 Style10" id="form3">
<p>
<label for="nom"></label>
<input type="text" name="nom" id="nom" accesskey="n" tabindex="30" />
</p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Prénom :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form4" class="Style3 Style10" id="form4">
<p>
<label for="Prénom"></label>
<input type="text" name="Prénom" id="Prénom" accesskey="p" tabindex="40" />
</p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Service :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form5" class="Style3 Style10" id="form5">
<p>
<label for="Service"></label>
<select name="Service" id="Service" accesskey="s" tabindex="50">
<option value="TM">Team Building</option>
<option value="IS">Incentives & Séminaires</option>
<option value="GP" selected="selected">Groupe Privé</option>
<option value="F1">Grand Prix F1</option>
<option value="Autres">Autres</option>
</select>
</p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Budget Moyen :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form6" class="Style10" id="form6">
<label for="Budget"></label>
<select name="Budget" id="Budget" accesskey="b" tabindex="60">
<option value="0 à 5000 €" selected="selected">0 à 5000 €</option>
<option value="5000 à 10 000 €">5000 à 10 000 €</option>
<option value="10 000 à 15 000 €">10 000 à 15 000 €</option>
<option value="15 000 à 30 000 €">15 000 à 30 000 €</option>
<option value="30 000 à 50 000 €">30 000 à 50 000 €</option>
<option value="50 000 à 85 000 €">50 000 à 85 000 €</option>
<option value="85 000 à 100 000 €">85 000 à 100 000 €</option>
<option value="100 000 à 150 000 €">100 000 à 150 000 €</option>
<option value="150 000 à 200 000 €">150 000 à 200 000 €</option>
<option value="200 000 à 500 000 €">200 000 à 500 000 €</option>
<option value="+ de 500 000 €">+ de 500 000 €</option>
</select>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Nombre de Participants:</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form7" class="Style3 Style10" id="form7">
<p><span id="sprytextfield2">
<label for="Participants"></label>
<input type="text" name="Participants" id="Participants" accesskey="x" tabindex="100" />
<span class="textfieldRequiredMsg Style9">Une valeur est requise.</span></span> </p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Date d'arrivée :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form8" class="Style3 Style10" id="form8">
<p><span id="sprytextfield3">
<label for="Arrivée"></label>
<input type="text" name="Arrivée" id="Arrivée" accesskey="a" tabindex="90" />
<span class="textfieldInvalidFormatMsg">jj/mm/aaaa</span><span class="textfieldMinValueMsg">La valeur entrée est inférieure au minimum requis.</span><span class="textfieldRequiredMsg">JJ/MM/AAAA.</span><span class="textfieldMaxValueMsg">La valeur entrée est supérieure au maximum autorisé.</span></span> </p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Date de départ :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form9" class="Style3 Style10" id="form9">
<p><span id="sprytextfield4">
<label for="départ"></label>
<input type="text" name="départ" id="départ" accesskey="z" tabindex="110" />
<span class="textfieldInvalidFormatMsg">jj/mm/aaaa</span></span> </p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Autres informations :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form10" class="Style3 Style3" id="form10">
<p>
<label for="Information"></label>
<textarea name="Information" id="Information" cols="45" rows="5" accesskey="f" tabindex="130">Précisez nous vos besoins.</textarea>
</p>
</form></td>
</tr>
<tr>
<td align="left" valign="top"><p>
<label for="valider">Envoyer vos données</label>
</p></td>
<td align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="form11" class="Style3 Style3" id="form11">
<p>
<label for="envoyer"></label>
<input name="valider" type="submit" id="envoyer" accesskey="f" tabindex="140" value="Envoyer " />
<input name="destinataire" type="hidden" id="destinataire" value="contact@monsite.com" />
</p>
</form></td>
</tr>
</table>
</fieldset>
</div>
</div>

et celui de ma page php

<?php

$to = "contact@monsite.com";
$subject = "Nouvelle demande";
$message = "Une nouvelle demande est arrivee \n
Societe: ".$_POST["Société"]." \n
Email: ".$_POST["email"]." \n
Nom: ".$_POST["nom"]." \n
Prenom: ".$_POST["Prénom"]." \n
Service: ".$_POST["Service"]." \n
Budget: ".$_POST["Budget"]." \n
Nombre de participants: ".$_POST["Participants"]." \n
Arrivee: ".$_POST["Arrivée"]." \n
Depart: ".$_POST["départ"]." \n
Information: ".$_POST["Information"]." \n";
$entete= "Form: $nom \n Reply-to: $email";
mail($to, $subject, $message, $headers);
echo "Votre demande a bien été envoyée."
?>
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Mimiste Messages postés 1149 Date d'inscription samedi 17 mai 2008 Statut Membre Dernière intervention 6 mars 2016 206
10 juin 2009 à 19:09
Ha oui, le probleme c'est que tu ouvre plusieur formulaire en fait. Tu doit ouvrir une seule fois le formulaire en haut de ta page, mettre tes champs, et le refermer une seule fois en bas de la page

<form action="nouvelle-demande.php" method="post" name="MonFormulaire">
les champs......
</form>
0
Tu veux dire que je dois effacer les lignes suivantes? Il ne va pas manquer des infos?

</form>
<form action="nouvelle-demande.php" method="post" name="form2" class="Style3 Style10" id="form2">
</form>
<form action="nouvelle-demande.php" method="post" name="form3" class="Style3 Style10" id="form3">
</form>
<form action="nouvelle-demande.php" method="post" name="form4" class="Style3 Style10" id="form4">
</form>
<form action="nouvelle-demande.php" method="post" name="form5" class="Style3 Style10" id="form5">
</form>
<form action="nouvelle-demande.php" method="post" name="form6" class="Style10" id="form6">
</form>
<form action="nouvelle-demande.php" method="post" name="form7" class="Style3 Style10" id="form7">
</form>
<form action="nouvelle-demande.php" method="post" name="form8" class="Style3 Style10" id="form8">
</form>
<form action="nouvelle-demande.php" method="post" name="form9" class="Style3 Style10" id="form9">
</form>
<form action="nouvelle-demande.php" method="post" name="form10" class="Style3 Style3" id="form10">
</form>
<form action="nouvelle-demande.php" method="post" name="form11" class="Style3 Style3" id="form11">
0
Mimiste Messages postés 1149 Date d'inscription samedi 17 mai 2008 Statut Membre Dernière intervention 6 mars 2016 206
10 juin 2009 à 22:33
Exactement, et il ne va rien manquer du tout non, il en faut qu'une seule de balise formulaire, et elle contiens plusieurs champs
0
Salut mimiste,

Merci pour ton aide.
J'ai tout éffacé mais mon champs societe à completement disparu.

<td width="379" align="left" valign="middle" bordercolor="#000080"><form action="nouvelle-demande.php" method="post" name="société" class="Style3 Style10" id="société">
<p>
<label for="societe"></label>
<input type="text" name="societe" id="societe" accesskey="s" tabindex="10" />
</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style3">
<div align="left">
<p class="Style10">Email :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p><span id="sprytextfield1">
<label for="email"></label>
<input type="text" name="email" id="email" accesskey="e" tabindex="20" />
<span class="textfieldRequiredMsg Style9">Adresse email complète.</span><span class="Style9 textfieldInvalidFormatMsg">Adresse email complète</span></span> </p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Nom :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p>
<label for="nom"></label>
<input type="text" name="nom" id="nom" accesskey="n" tabindex="30" />
</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Prénom :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p>
<label for="prenom"></label>
<input type="text" name="prenom" id="prenom" accesskey="p" tabindex="40" />
</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Service :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p>
<label for="service"></label>
<select name="service" id="service" accesskey="s" tabindex="50">
<option value="TM">Team Building</option>
<option value="IS">Incentives & Séminaires</option>
<option value="GP" selected="selected">Groupe Privé</option>
<option value="F1">Grand Prix F1</option>
<option value="Autres">Autres</option>
</select>
</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Budget Moyen :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<label for="budget"></label>
<select name="budget" id="budget" accesskey="b" tabindex="60">
<option value="0 à 5000 €" selected="selected">0 à 5000 €</option>
<option value="5000 à 10 000 €">5000 à 10 000 €</option>
<option value="10 000 à 15 000 €">10 000 à 15 000 €</option>
<option value="15 000 à 30 000 €">15 000 à 30 000 €</option>
<option value="30 000 à 50 000 €">30 000 à 50 000 €</option>
<option value="50 000 à 85 000 €">50 000 à 85 000 €</option>
<option value="85 000 à 100 000 €">85 000 à 100 000 €</option>
<option value="100 000 à 150 000 €">100 000 à 150 000 €</option>
<option value="150 000 à 200 000 €">150 000 à 200 000 €</option>
<option value="200 000 à 500 000 €">200 000 à 500 000 €</option>
<option value="+ de 500 000 €">+ de 500 000 €</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Nombre de Participants:</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p><span id="sprytextfield2">
<label for="participants"></label>
<input type="text" name="participants" id="participants" accesskey="x" tabindex="100" />
<span class="textfieldRequiredMsg Style9">Une valeur est requise.</span></span> </p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Date d'arrivée :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p><span id="sprytextfield3">
<label for="arrivee"></label>
<input type="text" name="arrivee" id="arrivee" accesskey="a" tabindex="90" />
<span class="textfieldInvalidFormatMsg">jj/mm/aaaa</span><span class="textfieldMinValueMsg">La valeur entrée est inférieure au minimum requis.</span><span class="textfieldRequiredMsg">JJ/MM/AAAA.</span><span class="textfieldMaxValueMsg">La valeur entrée est supérieure au maximum autorisé.</span></span> </p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Date de départ :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p><span id="sprytextfield4">
<label for="depart"></label>
<input type="text" name="depart" id="depart" accesskey="z" tabindex="110" />
<span class="textfieldInvalidFormatMsg">jj/mm/aaaa</span></span> </p>
</td>
</tr>
<tr>
<td align="left" valign="top"><div align="center" class="Style3 Style10">
<div align="left">
<p>Autres informations :</p>
</div>
</div></td>
<td align="left" valign="middle" bordercolor="#000080">
<p>
<label for="information"></label>
<textarea name="information" id="information" cols="45" rows="5" accesskey="f" tabindex="130">Précisez nous vos besoins.</textarea>
</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><p>
<label for="valider">Envoyer vos données</label>
</p></td>
<td align="left" valign="middle" bordercolor="#000080">
<p>
<label for="envoyer"></label>
<input name="valider" type="submit" id="envoyer" accesskey="f" tabindex="140" value="Envoyer " />
<input name="destinataire" type="hidden" id="destinataire" value="contact@vanilia-events.com" />
</p>
</form></td>
0
help!!!!!!!
0