Creation formulaire tableau

Résolu
guilich Messages postés 386 Date d'inscription   Statut Membre Dernière intervention   -  
guilich Messages postés 386 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

Bonjour,

Je viens à vous car je souhaite créer un formulaire intégrant un tableau, que je transmets par email.

J'ai donc pour cela suivi un modèle sur le net ce qui me donne le code suivant :

<div align=center>
<form method=POST action=formmail.php >
<input type=hidden name=subject value=Commande>
<table>
<tr><td colspan="3">Votre société:</td>
<td width="180"><input type=text name=Votre société size=30></td></tr>
<tr><td colspan="3">Votre Email:</td>
<td><input type=text name=Adresse Email size=30></td></tr>
<tr><td colspan="3">Sujet:</td>
<td><input type=text name=Informations Complémentaires size=30></td></tr>
<tr><td colspan="3">Informations complémentaires:</td>
<td><p>
<input type=text name=Informations size=30>
</p> </td></tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<tr>
<td width="61">Reference:</td>
<td width="183"><input type=text name="Reference" size=30></td></tr>
<td width="61">Quantite:</td>
<td><input name="quantite" type="text" value="" size="30" societe;="quantite" /></td>
</tr>
<tr>
<td width="61">Reference:</td>
<td width="183"><input type=text name="Reference2" size=30></td></tr>
<td width="61">Quantite:</td>
<td><input name="quantite" type="text" value="" size="30" societe;="quantite2" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>
</tr>
<tr>
<td>Référence</td>
<td><input type="text" name="Référence" société="société" size="30" /></td>
<td>Quantité</td>
<td><input type="text" name="Quantité" société="société" size="30" /></td>

</tr>
<tr><td colspan=4>Commentaires:<br>
<textarea COLS=50 ROWS=6 name=comments></textarea>
</td></tr>
</table>
<br />
<br> <input type=submit value=Envoyer> -
<input type=reset value=Annuler>
</form>
</div>

sur mon fichier index.html

et le suivant

<?php
$TO = "ADRESSE EMAIL";

$h = "From: " . $TO;

$message = "commande";

while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}

mail($TO, $subject, $message, $h);

Header("Location: http:// REDIRECTION WEB");

?>


Mon problème étant le suivant, lorsque je reçois le mail avec les informations, je reçois ceci.

[quote]commandesubject : Commande
Votre : BDI
Adresse : ADRESSE MAIL ENTREE
Informations : aucune
Reference : 900907
quantite : 2
reference1 :
quantite2 :
Quantité :
comments : AUCUN/quote


Le problème est donc le suivant, je ne parviens pas à recevoir deux lignes de référence / quantité dans le même mail.

Auriez-vous une réponse à me fournir ?

Merci d'avance
            
            
A voir également:

25 réponses

Stof37 Messages postés 601 Date d'inscription   Statut Membre Dernière intervention   148
 
Moi j'aurais fais:

if($Reference[$i]!="" && $Quantite[$i]!="")
non? Enfin j'ai peut être pas bien saisi à quelle condition tu veux ne pas les afficher
C'est pour quand un des deux est vide ou quand les deux sont vide que tu veux pas les afficher??
-1
guilich Messages postés 386 Date d'inscription   Statut Membre Dernière intervention   75
 
si les deux sont vides, pour éviter les problèmes lors de la saisie de commandes.
-1
Stof37 Messages postés 601 Date d'inscription   Statut Membre Dernière intervention   148
 
Bon alors deuxieme solution
-1
guilich Messages postés 386 Date d'inscription   Statut Membre Dernière intervention   75
 
où est-ce que je dois l'intégrer au juste ?

en dessous de ça ?

$Reference=$_POST['Reference'];
$Quantite=$_POST['Quantite'];


merci :)
-1
Goofyrocks Messages postés 20 Date d'inscription   Statut Membre Dernière intervention   1
 
nan dans le for tu rajoute juste
if($Reference[$i]!="" && $Quantite[$i]!="") si les deux sont vides on n'affiche pas
ou
if($Reference[$i]!="" || $Quantite[$i]!="") si un des deux est vide on n'affiche pas


$Reference=$_POST['Reference'];
$Quantite=$_POST['quantite'];
for($i=0;sizeof($Reference)>$i;$i++){
if($Reference[$i]!="" && $Quantite[$i]!="") $message .=" ref :".$Reference[$i]." qte ".$Quantite[$i]."\n";
}
$message.="Commentaire: ".$_POST['comments']."\n";

}
mail($to, $subject, $message, $from);

-1

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

Posez votre question
guilich Messages postés 386 Date d'inscription   Statut Membre Dernière intervention   75
 
ça me fait donc le code suivant

if(isset($_POST['subject'])){

$message.="Votre Societe: ".$_POST['Societe']."\n";
$message.="Votre Email: ".$_POST['Email']."\n";
$message.="Objet: ".$_POST['Sujet']."\n";

$message.="Information complementaire: ".$_POST['Informations']."\n";

$Reference=$_POST['Reference'];
$Quantite=$_POST['quantite'];
for($i=0;sizeof($Reference)>$i;$i++){
if($Reference[$i]!="" && $Quantite[$i]!="") $message .=" ref :".$Reference[$i]." qte ".$Quantite[$i]."\n";
$message .=" reference :".$Reference[$i]." quantite ". $Quantite[$i]."\n";
}
$message.="Commentaire: ".$_POST['Commentaire']."\n";

}


mais j'ai toujours la ligne vierge qui apparait
-1
Stof37 Messages postés 601 Date d'inscription   Statut Membre Dernière intervention   148
 
Pourquoi as tu mis 2 fois la ligne
$message .=" reference :".$Reference[$i]." quantite ". $Quantite[$i]."\n"; ?
Il ne faut laisser que celle du if sinon ca sert à rien
-1