Forum Moderators: coopster

Message Too Old, No Replies

changing email text output to html

         

Rissole

11:47 pm on Feb 8, 2011 (gmt 0)

10+ Year Member



I have an HTML page, called "Pre-test Information", getting useful form data from customers that sends a load of form data to the server. This calls a feedback.php script that emails the data back to me as a text file. All working fine.

How do I change the feedback.php script to return the data to me via email as a completed HTML page, ideally based on a blank "Pre-Test Information" template. Any code examples or tutorial info to look at much appreciated.

Or a way of parsing the emailed plain text file, straight into the HTML template?

regards
Rissole

Kings on steeds

5:42 am on Feb 10, 2011 (gmt 0)

10+ Year Member



if the input is html you can just add the content-type header to the php mail command


$headers = 'Content-type: text/html; charset=iso-8859-1';


then add the post to the body. If its not already html, have a pre built html file. use fopen/fread to load it to a string and then use str_replace to replace your {{#variables}} with your form input values,


$body = fread(fopen('template.html', r),filesize('template.html'));

$newbody = str_replace('{{#title}}',$_POST['title'],$body);
$newbody = str_replace('{{#body}}',$_POST['body'],$newbody);


good luck :-)