Jump to content

Remove empty fields from a form.


HHawk

Recommended Posts

Hi there,

I have a question regarding forms.
Currently we receive forms from our website, which is great and stuff, but there a lot of empty fields on our forms (since they are not all required to be filled in).

Is there a way to remove the empty fields completely before the form in sent by email?
So we get a cleaner order form by email?

Please advice and thanks in advance.
Link to comment
https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/
Share on other sites

[code]depends on how you process your form. if its just a case of you printing out each field in the form and its value then you could try:

[code]

$form_data = NULL:
foreach($_POST as $key => $val);
{
if (!empty($val))
{
  $form_data .= $key . ": " . $val . "\r\n";
}
}
[/code]

then just email yourslef the $form_data string.
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.