Benjamin, you are my father! Dude! That worked perfectly... In case you all didn't understand what I was trying to do, attached are some examples... This worked thanks to "Benjamin Vincent" ;-)
------------ snip 'customer_email.php' -------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <CENTER> <TABLE> <TR><TD><B>Username</B></TD><TD><B><?=$User?></B></TD></TR> <TR><TD><B>Password</B></TD><TD><B><?=$Password1?></B></TD></TR> <TR><TD><B>Company Code</B></TD><TD><B><?=$Company?></B></TD></TR> </TABLE> </CENTER> </body> </html> ------------ snip 'customer_email.php' -------------- ------------ snip 'emailtest.php' -------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>EMAIL include test</title> </head> <body> <?php $User = "test user"; $Password1 = "mypass"; $Company = "mycomp"; // email us to let us know there is a new user. $email = "[EMAIL PROTECTED]"; $subject = "email test"; $myname = "emailtest"; $myemail = "[EMAIL PROTECTED]"; $myreplyemail = $myemail; ob_start(); include("/www/secure.interactnetworks.com/customer_email.php"); $message = ob_get_contents(); ob_end_clean(); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".$myname." <".$myemail.">\r\n"; $headers .= "To: ".$email."\r\n"; $headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n"; $headers .= "X-Mailer: Linux Server"; mail($email, $subject, $message, $headers); echo $message; ?> check your email to see if this worked. </body> </html> ------------ snip 'emailtest.php' -------------- > -----Original Message----- > From: Benjamin Niemann [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 10, 2003 2:02 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] how can I use an external 'template' file > and still use PHP variables? > > > I think this should make it: > > ob_start(); > include("/pathto/customer_email.php"); > $message = ob_get_contents(); > ob_end_clean(); > > ----- Original Message ----- > From: "Daevid Vincent" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, January 10, 2003 10:48 AM > Subject: [PHP] how can I use an external 'template' file and > still use PHP > variables? > > > > I've posted this a few weeks ago with no response. I want to use an > > external > > "email template" as it were, so that the sales guys can > edit it as they > > like and simply shuffle the variables around that they need > > $username and $password (either with or without the <?php ?> tags). > > > > I don't want them mucking around in my code and potentially > screwing it > > up. Not to mention having a huge 'email' text in between those > > HTMLMESSAGE markers is ugly as hell and ends up making the > color-coding > > in HomeSite all kinds of whack at the end of it. > > > > I tried to use: > > > > $message = <<<HTMLMESSAGE > > include("/pathto/customer_email.php"); > > HTMLMESSAGE; > > > > But $message has the literal string > > ''include("/pathto/customer_email.php");'' instead of including the > > file. Grr.. (wouldn't it make sense that an include() > should be parsed > > FIRST with the contents put in place basically? This seems > like a 'bug' > > not a feature. > > > > I also tried: > > > > $filename = "/pathto/customer_email.php"; > > $fd = fopen ($filename, "r"); > > $message = fread ($fd, filesize ($filename)); > > fclose ($fd); > > > > But all the $username, etc. are treated as literals and if I use > > <?=$username?> in the customer_email.php the field is blank > (like it's > > being parsed but doesn't have a value for it or something), > instead of > > being converted to their actual PHP values. I also tried to put the > > "global" keyword in the customer_email.php file at the top. > > > > Ideally I would like to set things up so we have varoius form letter > > emails and I can switch them around based upon say a "special order > > code", where the $user/$pw is always the same (depending on > the database > > user of course), but the email content is different formats. > > > > Is there no way to accomplish this? Am I not being clear on > what it is > > I'm trying to accomplish? > > > > My final thought is to use some regex to search for > <?=$username?> in > > $message after it's all been read in, and replace it with > the variable > > $username or make up my own tag codes like [!username!] or something > > like that. This seems like such a hack, when PHP should be > able to do > > this natively somehow. > > > > Surely somebody out there has had to do this type of thing? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php