Need email to remove empty fields
I have a form with hundreds of fields. I want the email to show only the fields that are populated (that have something on the $_POST). I tried the bottom script - (added 'if(!empty...' line to what was generated by webassist) but it doesn't work:
<?php
if(!empty($_POST)) {
foreach( $_POST as $pkey => $pval ){
if (!RemoveValue($pkey,$remove,$removeBegins,$removeEnds,$removeIncludes)) {
if (get_magic_quotes_gpc()) $pval = stripslashes((is_array($pval)?implode(", ",$pval):$pval));
?>
<tr valign="top">
<th style="font-family: 'Times New Roman', Times, serif; font-size: 10px;width: 134px; text-align: right; padding: 3px 10px 3px 3px; color: #666; font-weight: bold;"><?php echo(str_replace("_"," ",$pkey)); ?>:</th>
<td style="font-family: 'Times New Roman', Times, serif; font-size: 10px;padding: 3px; border-left: 1px solid #DDD; color: #B6B6B6;"><?php echo(str_replace("\n","<BR />",(is_array($pval)?implode(", ",$pval):$pval))); ?></td>
</tr>
<?php
}
}
}
?>
Also, this form if very complex. I have it all built, but I may need your help. I need to get it to populate the db, one line per fieldset. May be hard to explain but you can see my form here: (I believe I have everything else working with some spaghetti code). :)
Thank you!