yoyo Posted January 7, 2008 Share Posted January 7, 2008 Hi i have a form which when Submitted goes to a page with the following code that emails the content. The content is embedded in a template. My problem is I can't get the date to appear in the mail.I need to make the date a key so i can just rap it in # # If anyone could help that would be grerat<?PHP$to = "myMail@gmail.com" . ", " ; // note the comma$to .= "myOther@gmail.com";/* subject */$subject = "Contract";$a = file_get_contents('template.html');foreach ($_POST as $key=>$value) { $a = str_replace("#".$key."#", $value, $a);}/* To send HTML mail, you can set the Content-type header. */$headers = "MIME-Version: 1.0\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* and now mail it */mail($to, $subject, $a, $headers);?> Link to comment Share on other sites More sharing options...
jhecht Posted January 7, 2008 Share Posted January 7, 2008 Well usually i would say look up a template parser, that would make this a lot easier. But i'll go through the long and ugly really quick:Loading the file: good. Now, here's what i would do:in your template file, have something like <%date%>, and then do this //File allready loaded, assumption;$a = str_replace("<%date%>",date('d F Y'),$a);//The rest of your code; But i would look up a template parser for PHP, and if all else fails, borrow the one from phpBB 2.0.x Link to comment Share on other sites More sharing options...
justsomeguy Posted January 8, 2008 Share Posted January 8, 2008 Wouldn't this work:$_POST['date'] = date(DATE_RFC822); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.