HHawk Posted January 5, 2007 Share Posted January 5, 2007 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 More sharing options...
ToonMariner Posted January 5, 2007 Share Posted January 5, 2007 [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] Link to comment https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/#findComment-153493 Share on other sites More sharing options...
HHawk Posted January 5, 2007 Author Share Posted January 5, 2007 Well it's just a simple html form... Don't know if that information matters? Link to comment https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/#findComment-153497 Share on other sites More sharing options...
ToonMariner Posted January 5, 2007 Share Posted January 5, 2007 well you can only remove that information if it is processed by a server side script like php or asp other wise what you get is what you get. Link to comment https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/#findComment-153729 Share on other sites More sharing options...
dbrimlow Posted January 5, 2007 Share Posted January 5, 2007 Actually, SOMETHING processes the form and submits the data (variables).Even using a straight sendmail cgi determines the format sent.Unless you are using some scarey FrontPage extension thing. Link to comment https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/#findComment-153733 Share on other sites More sharing options...
ToonMariner Posted January 5, 2007 Share Posted January 5, 2007 well if you can edit that script then you strip out the rubbish. Link to comment https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/#findComment-153740 Share on other sites More sharing options...
fenway Posted January 6, 2007 Share Posted January 6, 2007 If you really, really care, you could disable the inputs via JS before it gets submitted. Link to comment https://forums.phpfreaks.com/topic/32961-remove-empty-fields-from-a-form/#findComment-154517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.