I am developing a site for a client that has an application form and in short I am trying to use a php file to gather the submitted data and to then email the data within a structered layout set by html.
I am not having any problems with gathering the data, I am unable to pass the data through with the html. I have set up a variable named body.
$body = ’ <html> <head></head><body>//I have put my html code here and then within the html code winthin tables I am trying to display or print the data items submitted by the form. I tried to use short tags or full tags eg. <?=$one_first_name?> but that did not work.//</body></html> ';
The php $body variable is used within the mail() function and I have included the html php headers.
You could also use an external template. For example save the outline of your email in a standard HTML file but add tags in where you want specific information to go.
<html>
<body>
Dear __NAME__
Thank you for your order.
<body>
</html>
You could then read that in to your PHP script and use str_replace to put the contents of your variables in the correct place
$template will than contain your original email with the tags replaced with the content you have captured from the form.
That should make it a lot easier to maintain or change your email template at a later date.
Hey greenmedia, nice to see yet another local here at SitePoint!
I agree with GreenMedia, try to keep these templates away from your application code, chances are, sometime in the near future your going to have to let a ‘Designer’ near 'em.