Page 1 of 1

PHP Emailing Variables

Posted: Wed Oct 19, 2005 8:34 pm
by jetblack
I am setting up an inventory style form for a removalist company, i am wanting to have all the details of the form sent via email upon submission. I have the email working fine, it's just that the complete form has over 200 fields in the inventory where users post how many items they want removed.

My problem is if a user only wants to move say 1 item out of the 200, i only want that detail sent not the details of the complete 200 fields.

Is there a way to organize the email to only send the fields that have been entered. The fields that are sent also need to be labelled, so i know which item needs to be moved.

So i had to label each variable and that unfortunately is always sent in the email because it's just text, can you link the label to the variable in any way so if the user entered 0 for an item the variable is NOT sent in the email and neither is the variable's label?

Below is an excerpt from the email script in PHP.

Code: Select all

$emailObj->setContent("Thank You for your Quote submission: \n\nBelow are the details you entered:\n\nName: {Title} {Full_Name}\nEmployer: {Employer}\nPhone: H:{Home}W: {Work}M: {Mobile}\nEmail: {Email_Address}\nBEDROOM\nBedside Draws: {Bedside_Draws}\nBookshelf: {Bookshelf}\nBox Or Chest: {Box_Or_Chest}\nChair: {Chair}\nChest Of Draws: {Chest_Of_Draws}\nCot: {Cot}\nCupboard: {Cupboard}\nDesk: {Desk}\nDivan: {Divan}\nDouble Bed: {Double_Bed}\nDressing Table: {Dressing_Table}\nHeadboard: {Headboard}\nLamp: {Lamp}\nLowboy: {Lowboy}\nMirror: {Mirror}\nPortarobe: {Porta_Robe}\nPram: {Pram}\nQueen Bed: {Queen_Bed}\nSingle Bed: {Single_Bed}\nWardrobe: {Wardrobe}\nCartons: {Cartons}\nAdditional Items: {Additional_Bedroom_Items}");
   $emailObj->setEncoding("ISO-8859-1");
   $emailObj->setFormat("Text");
   $emailObj->setImportance("Normal");
   return $emailObj->Execute();
}
//end Trigger_SendEmail trigger


Any help from you gurus would be appreciated.

Posted: Wed Oct 19, 2005 9:04 pm
by feyd
since the data is available in an array, use looping to iterate over the values. Use another array that maps the field names to "plain english"