Forum Clubic

Formulaire PHP, envoyer seulement les champs complétés

J’aimerais savoir si en PHP c’est possible d’envoyer seulement les champs compléter. Je m’explique, voilà le code:

<?php

$destinataire = 'monsite@monsite.com' ; 
 
$txtMessage = "Nom: $nom    ";   
$txtMessage .= "Prenom: $prenom   ";  
$txtMessage .= "Tel.: résidence: $telresidence     ";  
$txtMessage .= "Tel.: bureau: $telbureau\n";  
$txtMessage .= "Note: $note\n";  
$txtMessage .= "Journée: $jour     ";  
$txtMessage .= "Heure: $heure     ";  
$txtMessage .= "Total avant taxe: $resultat\n\n";  

$txtMessage .= "MAKI\n"  ;   
$txtMessage .= "Anguille grillée:  $case22    ";      
$txtMessage .= "Beijing:  $case23    ";      
$txtMessage .= "Boston:  $case24    ";      
$txtMessage .= "Boston deluxe:  $case25    ";      
$txtMessage .= "Butterfly:  $case26    ";         
$txtMessage .= "California:  $case27    ";      
$txtMessage .= "California deluxe:  $case28    ";      
$txtMessage .= "Crevette tempura:  $case29    ";      
$txtMessage .= "Florida:  $case30    ";    
$txtMessage .= "Ixtapa:  $case31    ";      
$txtMessage .= "Kamikaze au saumon:   $case32     ";      
$txtMessage .= "Kamikaze au thon:   $case33     ";      
$txtMessage .= "Philadelphia:  $case34     ";    
$txtMessage .= "Samurai:  $case35     ";    
$txtMessage .= "Tartare de pétoncle:  $case36     ";      
$txtMessage .= "Tartare de saumon:  $case37     ";      
$txtMessage .= "Tartare de thon:  $case38     ";      
$txtMessage .= "Vancouver:  $case39     ";    
$txtMessage .= "Neuf un un:  $case40     ";      
$txtMessage .= "Neuf un un tempura:  $case41    \n\n";   

$txtMessage .= "TEMAKI\n"  ; 
$txtMessage .= "Anguille grillée:  $case1     ";      
$txtMessage .= "Beijing:  $case2     ";      
$txtMessage .= "Boston:  $case3     ";      
$txtMessage .= "Boston deluxe:  $case4     ";      
$txtMessage .= "Butterfly:  $case5     ";         
$txtMessage .= "California:  $case6     ";      
$txtMessage .= "California deluxe:  $case7     ";      
$txtMessage .= "Crevette tempura:  $case8     ";      
$txtMessage .= "Florida:  $case9     ";    
$txtMessage .= "Ixtapa:  $case10     ";      
$txtMessage .= "Kamikaze au saumon:  $case11     ";      
$txtMessage .= "Kamikaze au thon:  $case12     ";      
$txtMessage .= "Philadelphia:  $case13     ";    
$txtMessage .= "Samurai:  $case14     ";    
$txtMessage .= "Tartare de pétoncle:  $case15     ";      
$txtMessage .= "Tartare de saumon:  $case16     ";      
$txtMessage .= "Tartare de thon:  $case17     ";      
$txtMessage .= "Vancouver:  $case18     ";    
$txtMessage .= "Neuf un un:  $case19     ";      
$txtMessage .= "Neuf un un tempura:  $case20     ";   
$txtMessage .= "Temaki Unimer:  $case21     \n\n";  

$txtMessage .= "NIGIRI\n"  ;   
$txtMessage .= "Ebi:  $case42     ";      
$txtMessage .= "Hotategai:  $case43     ";      
$txtMessage .= "Ikura:  $case44     ";      
$txtMessage .= "Izumi dai:  $case45     ";      
$txtMessage .= "Kanikama:  $case46     ";         
$txtMessage .= "Kunsei sake:  $case47     ";      
$txtMessage .= "Maguro:  $case48     ";      
$txtMessage .= "Saba:  $case49     ";      
$txtMessage .= "Sake:  $case50     ";    
$txtMessage .= "Sake teriyaki:  $case51     ";      
$txtMessage .= "Soleil levant:  $case52     ";      
$txtMessage .= "Tako:  $case53     ";      
$txtMessage .= "Tamago:  $case54     ";    
$txtMessage .= "Tobiko:  $case55     ";    
$txtMessage .= "Unagi:  $case56     \n\n"; 
 
$txtMessage .= "SASHIMI\n"  ;   
$txtMessage .= "Ebi:  $case57     ";      
$txtMessage .= "Hotategai:  $case58     ";      
$txtMessage .= "Ikura:  $case59     ";      
$txtMessage .= "Izumi dai:  $case60     ";      
$txtMessage .= "Kanikama:  $case61     ";         
$txtMessage .= "Kunsei sake: $case62     ";      
$txtMessage .= "Maguro:  $case63     ";      
$txtMessage .= "Saba:  $case64     ";      
$txtMessage .= "Sake:  $case65     ";    
$txtMessage .= "Sake teriyaki:  $case66     ";      
$txtMessage .= "Soleil levant:  $case67     ";      
$txtMessage .= "Tako:  $case68     ";      
$txtMessage .= "Tamago:  $case69     ";    
$txtMessage .= "Tobiko:  $case70     ";    
$txtMessage .= "Unagi:  $case71     \n\n";  
 
$txtMessage .= "MAKI VEGETARIEN\n"  ;   
$txtMessage .= "Exotique:  $case72     ";      
$txtMessage .= "Goma wakame:  $case73     ";      
$txtMessage .= "Jardinier:  $case74     ";      
$txtMessage .= "Popeye:  $case75     ";      
$txtMessage .= "Tropical:  $case76     \n\n";         

$txtMessage .= "HOZOMAKI\n"  ;   
$txtMessage .= "Avocado:  $case77     ";      
$txtMessage .= "Kanikama:  $case78     ";      
$txtMessage .= "Kappa:  $case79     ";      
$txtMessage .= "Mango:  $case80     ";      
$txtMessage .= "Ninjin:  $case81     ";      
$txtMessage .= "Sake:  $case82     ";      
$txtMessage .= "Tamago:  $case83     ";    
$txtMessage .= "Tekka:  $case84     \n\n";      

$txtMessage .= "ASSIETTES ASSORTIES\n"  ;   
$txtMessage .= "Assiette végétarienne:  $case85     ";      
$txtMessage .= "Assiette de mini-maki:  $case86     ";      
$txtMessage .= "Assiette débutant:  $case87     ";      
$txtMessage .= "Assiette découverte:  $case88     ";      
$txtMessage .= "Assiette dégustation:  $case89     ";      
$txtMessage .= "Assiette Unimer:  $case90     ";      
$txtMessage .= "Assiette deluxe:  $case91     ";    
$txtMessage .= "Assiette shogun:  $case92     ";  
$txtMessage .= "Assiette empereur:  $case93     \n\n";  
 
 
$URL= "http://www.monsite.com";

mail($destinataire, $txtSujet, $txtMessage ); 
header ("Location: $URL");
        
  
?> 

Si la personne ne sélectionne que 2 ou 3 items dans le formulaire, je ne veux pas recevoir les 90 autres champs non complétés.

Si. Tu vérifies le contenu de $caseXX avant.

Genre :

if (!empty($case93)) $txtMessage .= “Assiette empereur: $case93 \n\n”;

Maintenant, faire des $caseXX je trouve ça très crade, et très peu réutilisable/maintenable. Avec plus de détails, et plus de ton temps, tu devrais pouvoir améliorer ça. Surtout si c’est pour le menu d’un restaurant.

Merci