# Exclude empty form fields from email

**URL:** <https://forum.kirupa.com/t/exclude-empty-form-fields-from-email/307124>\
**Category:** Uncategorized\
**Created:** [March 29, 2010, 1:56am UTC](https://forum.kirupa.com/t/exclude-empty-form-fields-from-email/307124 "2010-03-29T01:56:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![strawberry](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@strawberry](https://forum.kirupa.com/u/strawberry)\
**Post date:** [March 29, 2010, 1:56am UTC](https://forum.kirupa.com/t/exclude-empty-form-fields-from-email/307124/1 "2010-03-29T01:56:18Z")

</div>

Hi all  
I am trying to avoid submitting fields that are left empty in my flash form.  
I dont really want to receive all the **field names** in my email if they dont have any value.

This is the php code I am using with my flash form:

```php

<?  
$adminaddress = "myemail@domain.com"; 
$siteaddress =www.mydomain.com; 
$sitename = "My Company"; 
 
$date = date("m/d/Y H:i:s");
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);
 
if ($action != ""): 
mail("$adminaddress","Online Order", 
"Details:

Name: $pname 
Event Date: $party_date
Event Time: $event_time
Delivery Date: $delivery_date
Delivery Time: $delivery_time
Number of Guests: $guests
Cake Design: $design_choice
Order 1
Cake Flavor: $color - Other Flavor: $other_flavor
Cake Filling1: $style - Other Filling 1: $other_1_filling
Cake Filling2: $shape - Other Filling 2: $other_2_filling
Special Instructions:
------------------------------
$special_instructions
------------------------------
Optional Order 2
Cake Flavor2: $polishing -Other Flavor Combo 2: $other_flavor_combo2
Cake Filling1: $design - Other Filling 1 Combo 2: $other_filling1_combo2
Cake Filling2: $lettering - Other Filling 2 Combo 2: $other_filling2_combo2
------------------------------
 
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress"); 
mail("$email","Thank you from $sitename", 
"This message is to confirm we have received the order information for: $pname

Best Regards,
$sitename
$siteaddress","FROM:$adminaddress"); 
$sendresult = "Thank you for visiting <a href = \"$siteaddress\" target = \"_blank\"><u>$sitename</u></a>. You will receive a confirmation email shortly. ";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo "$send_answer";
endif;
?>
 

```

The field names I would like to avoid receiving, if empty, are:

Other Flavor: $other\_flavor  
Other Filling 1: $other\_1\_filling  
Other Filling 2: $other\_2\_filling

Other Flavor Combo 2: $other\_flavor\_combo2  
Other Filling 1 Combo 2: $other\_filling1\_combo2  
Other Filling 2 Combo 2: $other\_filling2\_combo2

Here is a little description of how the form works:  
Unless users cannot find their preferred flavor or fillings in the correspondent drop down menu present on my flash form, then they must select "_ **others"** _ and specify ther flavor in the “Other Flavor” text field.  
Same goes for the cake fillings 1, filling 2 etc.

If they find their flavor and fillings in the drop down menu (most of the times they do), these “others - specify” fields will always be empty…

Hope I was able to explain it and someone can help me accomplish this…  
thank you
