Link to home
Start Free TrialLog in
Avatar of kimberlys777
kimberlys777Flag for United States of America

asked on

How do I format captured form data into a table to send in email

The code below is from the processing script for a form.  I want to format the captured data as a 2 column table - [fieldname] [value] in the email that is sent.  
//Sending Email to form owner
$pfw_header = "From: PatientReferral@ckids.org\n"
  . "Reply-To: PatientReferral@ckids.org\n";
$pfw_subject = "Admin Email with All Fields data - $medSpecialties";
$pfw_email_to = "PatientReferral@ckids.org";
$pfw_message = "medSpecialties:   $medSpecialties\n"
. "surgSpecialties:   $surgSpecialties\n"
. "Patient Name:   $patName\n"
. "Date of Birth:   $patDOB\n"
. "Parent/Guardian:   $parent2\n"
. "Preferred Phone 1:   $prePhone1\n"
. "Preferred Phone 2:   $prefPhone\n"
. "DCF:   $dcf\n"
. "Social Worker Name: $socialWkrName\n"
. "Social Worker Phone: $socialWkrPhone2\n"
. "Residential Placement: $resPlacement\n"
. "Residential Placement Address: $resAddress\n"
. "Residential Placement Phone: $resPhone\n"
. "Completed On-line Appointment Request: $onlineAppt\n"
. "Household Language Preference (other than English): $houseLang\n"
. "Household Language Preference: $houseLangOther2\n"
. "Translation Services Needed: $translationSvcs\n"
. "Hearing Impaired Services Needed: $hearingSvcs\n"
. "Referring Provider Name: $refProviderName2\n"
. "Referring Provider Phone: $refProviderPhone2\n"
. "Referring Provider Fax: $refProviderFax2\n"
. "Referring Provider Email: $refProviderEmail2\n"
. "Other Pediatric Specialist Name1: $MDName1\n"
. "Other Pediatric Specialist Specialty1: $MDSpecialty1\n"
. "Other Pediatric Specialist Name2: $MDName2\n"
. "Other Pediatric Specialist Specialty2: $MDSpecialty2\n"
. "Other Pediatric Specialist Name3: $MDName3\n"
. "Other Pediatric Specialist Specialty3: $MDSpecialty3\n"
. "Reason for Referral: $refReason2\n"
. "Is Family Aware of Referral Reason: $famAware\n"
. "Provider Call Requested: $providerCall\n"
. "Initiate Co-management Protocol (if available): $coMgmtProtocol\n"
. "Patient Name: $patName3\n"
. "Date of Birth: $patDOB3\n"
. "Sex: $patSex2\n"
. "Home Phone: $patPhone2\n"
. "Cell Phone: $patCell2\n"
. "Work Phone: $patWorkPhone2\n"
. "Address: $patAddress2\n"
. "PO Box: $patPOBox\n"
. "City: $patCity2\n"
. "State: $patState2\n"
. "Zip: $patZip2\n"
. "Guarantor: $guarantor\n"
. "Primary Language (if other than English): $patLanguage\n"
. "Insurance Primary: $insPrimary\n"
. "Primary ID Number: $insPrimaryID\n"
. "Specialist Co-Pay: $patPrimaryCopay\n"
. "Insurance Secondary: $patInsSecondary\n"
. "Secondary ID Number: $patIDNumSecondary\n"
. "Specialist Co-Pay: $patSecondaryCopay\n"
. "TodaysDate: $TodaysDate\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

Open in new window

Avatar of AtanAsfaloth
AtanAsfaloth

The easiest way to accomplish this is probably to send the email as HTML, and then generate an HTML table. To send the email as HTML, simply change your $pfw_header to the following.

Atan

$pfw_header = "From: PatientReferral@ckids.org\n"
  . "Reply-To: PatientReferral@ckids.org\n"
  . "MIME-Version: 1.0\n"
  . "Content-type: text/html; charset=iso-8859-1");

Open in new window

The closing parenthesis obviously shouldn't be there. Sorry about that.
$pfw_header = "From: PatientReferral@ckids.org\n"
  . "Reply-To: PatientReferral@ckids.org\n"
  . "MIME-Version: 1.0\n"
  . "Content-type: text/html; charset=iso-8859-1";

Open in new window

Avatar of kimberlys777

ASKER

Thanks.  I'm a little closer now.  I no longer get an error (whew!)  It sends the email but now it's one long line of text with no formatting.  Can you tell me how to format it into a table?
ASKER CERTIFIED SOLUTION
Avatar of AtanAsfaloth
AtanAsfaloth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FANTASTIC!!! It works!  Thank you so much.  Now I'm going to open a new question to try to get the results to print out on the confirmation page.  once again... THANK YOU!!!
AtanAsfaloth - I can't thank you enough.  I'd been trying to figure this out for 2 days.  Your quick, polite and easy-to-understand solutions are greatly appreciated.