How to return only completed fields from a form

I created a request form with lots of variables that shoots me an email when it is submitted and I am trying to figure out how to make it submit only the data from the fields that were completed and not from all the others. There is a long list of checkboxes on the HTML form and I want the email to include only the items the users checked.

Currently I have a PHP file which creates a variable for each field that is posted and then a $body variable which lists the value of each variable for inclusion in the email message. Thanks for any help!

You can check it by 2 ways :

- Javascript : You can't let user to submit the form without a cheking of the fields.
- Php : After sending the form, you check if the fields ar filled.

I recommend use 2 ways at the same time, because the javascript way it’s more efficiency (you don’t refresh the web), but it’s executed inside users computer, and it can be modified by user.

Simple example:
[php]

<?php if($_POST['name']!='') && $_POST['surname']!=''){ // this check if fields not empty in php } ?> Name : Surname : [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service