?
Solved

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

Posted on 2009-04-29
6
Medium Priority
?
322 Views
Last Modified: 2013-12-13
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

0
Comment
Question by:kimberlys777
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:AtanAsfaloth
ID: 24267693
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

0
 
LVL 5

Expert Comment

by:AtanAsfaloth
ID: 24267698
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

0
 

Author Comment

by:kimberlys777
ID: 24267774
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?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
AtanAsfaloth earned 2000 total points
ID: 24267881
Of course. The idea is to build your email just as if it's a web page. This will generate a table with two rows for the first two fieldnames and their values.
$pfw_message = "<html><body><table border=\"0\">"
  . "<tr><td>medSpecialties:</td><td>$medSpecialties</td></tr>"
  . "<tr><td>surgSpecialties:</td><td>$surgSpecialties</td></tr>"
  . "</table></body></html>";

Open in new window

0
 

Author Comment

by:kimberlys777
ID: 24270061
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!!!
0
 

Author Closing Comment

by:kimberlys777
ID: 31576300
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month16 days, 23 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question