Jump to content

i dont want to include blank form fields when emailed


corics15

Recommended Posts

hello everyone!

  I have at least 45 fields in my form and only 8 of them are required namely, NAME, GENDER, DATE OF BIRTH, AGE, HEIGHT, WEIGHT, EMAIL AND CONTACT NO. The rest is optional. The problem is, I dont want to include the blank fields which have not been filled up when the SUBMIT button is clicked. I just want the fields which has been filled up to appear in the mail recipient.

  Could anybody help, please?

Link to comment
Share on other sites

i understand that I have to use an array, foreach and the if statement, but i don't have any idea how to implement it in code  ???  :'(,  my head aches... :-[

well, after researching, i found out that:

1. store the field values in an array

2. loop through each values and check if the fields are empty and store in the second array

3. print the values in the the second array using the list command

 

but i don't have any idea how to implement it in code...

function DoStripSlashes($FieldValue) 
{ 
if ( get_magic_quotes_gpc() ) { 
  if (is_array($FieldValue) ) { 
   return array_map('DoStripSlashes', $FieldValue); 
  } else { 
   return stripslashes($FieldValue); 
  } 
} else { 
  return $FieldValue; 
} 
}

/* filterchars and dostripslashes were ommitted in this line */

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}

$FTGfirst_name = DoStripSlashes( $_REQUEST['first_name'] );
$FTGlast_name = DoStripSlashes( $_REQUEST['last_name'] );
$FTGgender = DoStripSlashes( $_REQUEST['gender'] );
$FTGany_date_month = DoStripSlashes($_REQUEST['any_date_month']);
$FTGany_date_day = DoStripSlashes($_REQUEST['any_date_day']);
$FTGany_date_year = DoStripSlashes($_REQUEST['any_date_year']);
$FTGage = DoStripSlashes( $_REQUEST['age'] );
$FTGheight = DoStripSlashes( $_REQUEST['height'] );
$FTGweight = DoStripSlashes( $_REQUEST['weight'] );
$FTGreligion = DoStripSlashes( $_REQUEST['religion'] );
$FTGcivil_status = DoStripSlashes( $_REQUEST['civil_status'] );
$FTGpassport_no = DoStripSlashes( $_REQUEST['passport_no'] );
$FTGcoll_univ = DoStripSlashes( $_REQUEST['coll_univ'] );
$FTGcoll_univ_course = DoStripSlashes( $_REQUEST['coll_univ_course'] );
$FTGcoll_graduate = DoStripSlashes( $_REQUEST['coll_graduate'] );
$FTGtech_voc = DoStripSlashes( $_REQUEST['tech_voc'] );
$FTGtech_voc_course = DoStripSlashes( $_REQUEST['tech_voc_course'] );
$FTGtech_voc_graduate = DoStripSlashes( $_REQUEST['tech_voc_graduate'] );
$FTGhigh_sch = DoStripSlashes( $_REQUEST['high_sch'] );
$FTGco_name = DoStripSlashes( $_REQUEST['co_name'] );
$FTGco_name_add = DoStripSlashes( $_REQUEST['co_name_add'] );
$FTGco_prod = DoStripSlashes( $_REQUEST['co_prod'] );
$FTGco_jobdesc = DoStripSlashes( $_REQUEST['co_jobdesc'] );
$FTGco_name2 = DoStripSlashes( $_REQUEST['co_name2'] );
$FTGco_name_add2 = DoStripSlashes( $_REQUEST['co_name_add2'] );
$FTGco_prod2 = DoStripSlashes( $_REQUEST['co_prod2'] );
$FTGco_jobdesc2 = DoStripSlashes( $_REQUEST['co_jobdesc2'] );
$FTGco_name3 = DoStripSlashes( $_REQUEST['co_name3'] );
$FTGco_name_add3 = DoStripSlashes( $_REQUEST['co_name_add3'] );
$FTGco_prod3 = DoStripSlashes( $_REQUEST['co_prod3'] );
$FTGco_jobdesc3 = DoStripSlashes( $_REQUEST['co_jobdesc3'] );
$FTGco_name4 = DoStripSlashes( $_REQUEST['co_name4'] );
$FTGco_name_add4 = DoStripSlashes( $_REQUEST['co_name_add4'] );
$FTGco_prod4 = DoStripSlashes( $_REQUEST['co_prod4'] );
$FTGco_jobdesc4 = DoStripSlashes( $_REQUEST['co_jobdesc4'] );
$FTGco_name5 = DoStripSlashes( $_REQUEST['co_name5'] );
$FTGco_name_add5 = DoStripSlashes( $_REQUEST['co_name_add5'] );
$FTGco_prod5 = DoStripSlashes( $_REQUEST['co_prod5'] );
$FTGco_jobdesc5 = DoStripSlashes( $_REQUEST['co_jobdesc5'] );
$FTGco_name6 = DoStripSlashes( $_REQUEST['co_name6'] );
$FTGco_name_add6 = DoStripSlashes( $_REQUEST['co_name_add6'] );
$FTGco_prod6 = DoStripSlashes( $_REQUEST['co_prod6'] );
$FTGco_jobdesc6 = DoStripSlashes( $_REQUEST['co_jobdesc6'] );
$FTGspec_skills = DoStripSlashes( $_REQUEST['spec_skills'] );
$FTGmach_types = DoStripSlashes( $_REQUEST['mach_types'] );
$FTGemail = DoStripSlashes( $_REQUEST['email'] );
$FTGcontact_no = DoStripSlashes( $_REQUEST['contact_no'] );

 

well here is the code for you guys to check...hope you can help me out...thanks...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.