Re: [PHP] email templates and str_replace

2001-06-20 Thread Zak Greant

Hi Richard,

You are replacing the placeholders in $mail_template, but you are storing
the results in $mail_content.

 $mail_content = str_replace('##fullname##',$fullname,$mail_template);
 $mail_content = str_replace('##email##',$email,$mail_template);

This means that each time you call the str_replace function, you are
overwriting what was generated by the previous call to str_replace.

Just change $mail_content to $mail_template and everything should work.

--zak

- Original Message -
From: Richard Kurth [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 20, 2001 2:32 AM
Subject: [PHP] email templates and str_replace


   I am trying to set up a template for an email program below you will
   see the test program the $mail_template is pulled from a database
   that is pre saved when it is saved the Placeholders are filled in
   using str_replace. that is what I want it to do. But it does not work.
What am
   I missing hear.

 $mail_template= html
 head
 titleWeb Hosting At ##hostdomain## /title
 /head

 body bgcolor='#C4C9DB'
 font size='4' color='#008080'strongDear ##fullname## /strong/font
 brbr
 font size='4' color='#008080'strongYour webhosting account has been
created. Please use the following data to log in to ##domain##
/strong/font
 br
 font size='4' color='#008080'
 strongul type=square
 liDomain:##domain##   /li
 liIP-Address: ##ip## /li
 liUsername: ##username##/li
 liPassword: ##password##/li
 liMysql Database: ##userdatabase##  /li
 liMysql Username: ##newuser## /li
 liMysql Password: ##newuserpass## /li
 /ul  /strong
 /font

 font size='4' color='#008080'strongThanks for choosing ##hostdomain##
br Any Questions e-mail ##sales##@##hostdomain##/strong /font

 /body
 /html
 ;

 /* message*/
 //$mail_template = $message;

 $fullname=Richard Kurth;
  $email=[EMAIL PROTECTED];
  $hostdomain=northwesthost.com;
  $hostname=www;
  $domain=twohot;
   $tld=.com;
  $baseip=234.444.45.444;
  $username=rkurth;
  $password=boat;
  $userdatabase=twohot;
  $newuser=twohot;
  $newuserpass=twohot;
  $sales=sales;
 $domainname=$hostname . . . $domain . $tld;


 $mail_content = str_replace('##fullname##',$fullname,$mail_template);
 $mail_content = str_replace('##email##',$email,$mail_template);
 $mail_content = str_replace('##domain##',$domainname,$mail_template);
 $mail_content = str_replace('##ip##',$baseip,$mail_template);
 $mail_content = str_replace('##username##',$username,$mail_template);
 $mail_content = str_replace('##password##',$password,$mail_template);
 $mail_content =
str_replace('##userdatabase##',$userdatabase,$mail_template);
 $mail_content = str_replace('##newuser##',$newuser,$mail_template);
 $mail_content =
str_replace('##newuserpass##',$newuserpass,$mail_template);
 $mail_content = str_replace('##hostdomain##',$hostdomain,$mail_template);
 $mail_content = str_replace('##sales##',$sales,$mail_template);
 /* and now mail it */
 /* recipients */
 $recipient = $fullname $email ;
 //header
 $headers .=From: Sales Department  [EMAIL PROTECTED] \n;
 $headers .= reply-To:$from\nX-Mailer: PHP/ .phpversion(). \n;
 $headers .= Content-Type: text/html; charset=iso-8859-1\n;
 //subject
 $subject1 = $subject;
 //mail($recipient, $subject1, $mail_content, $headers);
 //print $recipient, $subject1, $mail_content, $headers;
 echo $mail_content;











 Best regards,
  Richard
 mailto:[EMAIL PROTECTED]





Re: [PHP] email templates and str_replace

2001-06-20 Thread Chris \TunkeyMicket\ Watford



Mr. Kurth,

 Try this. Save the mail 
template to another file [like mailtemplate.txt] then open it for 
reading.

//read in template
$template = 
file("mailtemplate.txt");

//setup variables
$fullname="Richard 
Kurth";$email="[EMAIL PROTECTED]";$hostdomain="northwesthost.com"; 
$hostname="www"; $domain="twohot"; 
 
$tld=".com";$baseip="234.444.45.444";$username="rkurth";$password="boat";$userdatabase="twohot";$newuser="twohot";$newuserpass="twohot";$sales="sales";$domainname=$hostname 
. "." . $domain . $tld;

//iterate through the template replacing 
the items
for($i = 0; $i  sizeof($template); 
$i++) {
 $template[i] = 
str_replace('##fullname##',$fullname,$template[i]); 
$template[i] = str_replace('##email##',$email,$template[i]);
 $template[i] = 
str_replace('##domain##',$domainname,$template[i]); 
$template[i] = str_replace('##ip##',$baseip,$template[i]); 
$template[i] = 
str_replace('##username##',$username,$template[i]); 
$template[i] = 
str_replace('##password##',$password,$template[i]); 
$template[i] = 
str_replace('##userdatabase##',$userdatabase,$template[i]); 
$template[i] = 
str_replace('##newuser##',$newuser,$template[i]); 
$template[i] = 
str_replace('##newuserpass##',$newuserpass,$template[i]); 
$template[i] = 
str_replace('##hostdomain##',$hostdomain,$template[i]); 
$template[i] = str_replace('##sales##',$sales,$template[i]); 

}

//Now the array $template contains our 
message, parsed and all
//from here we can implode it into one 
string, or we can leave
//it be to do further things to 
it.The example from above is
//similar to the method I use in my 
TemplateEngine I wrote a
//little while back, I might just include 
the source some time.

Hope this helps,

Chris "TunkeyMicket" Watford

TunkeyMicket Productions
www.tunkeymicket.com

- Original Message - 
From: "Richard Kurth" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 20, 2001 4:32 AM
Subject: [PHP] email templates and 
str_replace
  I am trying to set up a template for an email program below 
you will  see the test program the $mail_template is pulled from a 
database  that is pre saved when it is saved the Placeholders are 
filled in  using str_replace. that is what I want it to do. But it 
does not work. What am  I missing hear.  
$mail_template= "html head 
 titleWeb Hosting At 
##hostdomain## /title /head  body 
bgcolor='#C4C9DB' font size='4' 
color='#008080'strongDear ##fullname## /strong/font 
 brbr font size='4' 
color='#008080'strongYour webhosting account has been created. 
Please use the following data to log in to ##domain## 
/strong/font br font size='4' 
color='#008080' strongul type=square 
 
liDomain:##domain## /li 
 liIP-Address: ##ip## 
/li  
liUsername: ##username##/li 
 liPassword: 
##password##/li  
liMysql Database: ##userdatabase## /li 
 liMysql Username: ##newuser## 
/li  liMysql 
Password: ##newuserpass## /li /ul 
/strong /font
font size='4' color='#008080'strongThanks for choosing 
##hostdomain## br Any Questions e-mail ##sales##@##hostdomain##/strong /font  /body 
/html ";  /* message*/ //$mail_template 
= $message;  $fullname="Richard Kurth"; 
$email="[EMAIL PROTECTED]"; 
$hostdomain="northwesthost.com"; $hostname="www"; 
$domain="twohot";  $tld=".com"; 
$baseip="234.444.45.444"; $username="rkurth"; 
$password="boat"; $userdatabase="twohot"; 
$newuser="twohot"; $newuserpass="twohot"; 
$sales="sales"; $domainname=$hostname . "." . $domain . 
$tld;   $mail_content = 
str_replace('##fullname##',$fullname,$mail_template); $mail_content = 
str_replace('##email##',$email,$mail_template); $mail_content = 
str_replace('##domain##',$domainname,$mail_template); $mail_content = 
str_replace('##ip##',$baseip,$mail_template); $mail_content = 
str_replace('##username##',$username,$mail_template); $mail_content = 
str_replace('##password##',$password,$mail_template); $mail_content = 
str_replace('##userdatabase##',$userdatabase,$mail_template); 
$mail_content = str_replace('##newuser##',$newuser,$mail_template); 
$mail_content = 
str_replace('##newuserpass##',$newuserpass,$mail_template); 
$mail_content = 
str_replace('##hostdomain##',$hostdomain,$mail_template); $mail_content 
= str_replace('##sales##',$sales,$mail_template); /* and now mail it 
*/ /* recipients */ $recipient = "$fullname $email" ; 
 //header $headers .="From: Sales Department  [EMAIL PROTECTED] 
\n"; $headers .= "reply-To:$from\nX-Mailer: PHP/" .phpversion()." 
\n"; $headers .= "Content-Type: text/html; 
charset=iso-8859-1\n"; //subject $subject1 = $subject; 
//mail($recipient, $subject1, $mail_content, $headers); //print 
"$recipient, $subject1, $mail_content, $headers"; echo 
$mail_content;   
 Best regards, 
Richard  mailto:[EMAIL PROTECTED]


RE: [PHP] email templates and str_replace

2001-06-20 Thread Rich Cavanaugh

Richard,
The problem is with the str_replace()s. Consider the following:

?php
$myvar = 'this is a var.';
$mytext = str_replace('is', 'is not', $myvar);
?

At this point $myvar still equals 'this is a var.' but $mytext is 'this is
not a var.' $myvar hasn't been modfified by the str_replace so any
additional str_replace()s after it will not have a cumlative effect.

?php
$mail_content = $mail_template;

$mail_content = str_replace('##fullname##',$fullname,$mail_content);
$mail_content = str_replace('##email##',$email,$mail_content);
$mail_content = str_replace('##domain##',$domainname,$mail_content);
?

Something like the above would have the effect you're looking for.

--
Rich Cavanaugh
CTO, EnSpot.com

-Original Message-
From: Richard Kurth [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 4:32 AM
To: [EMAIL PROTECTED]
Subject: [PHP] email templates and str_replace


  I am trying to set up a template for an email program below you will
  see the test program the $mail_template is pulled from a database
  that is pre saved when it is saved the Placeholders are filled in
  using str_replace. that is what I want it to do. But it does not work.
What am
  I missing hear.

$mail_template= html
head
titleWeb Hosting At ##hostdomain## /title
/head

body bgcolor='#C4C9DB'
font size='4' color='#008080'strongDear ##fullname## /strong/font
brbr
font size='4' color='#008080'strongYour webhosting account has been
created. Please use the following data to log in to ##domain##
/strong/font
br
font size='4' color='#008080'
strongul type=square
liDomain:##domain##   /li
liIP-Address: ##ip## /li
liUsername: ##username##/li
liPassword: ##password##/li
liMysql Database: ##userdatabase##  /li
liMysql Username: ##newuser## /li
liMysql Password: ##newuserpass## /li
/ul  /strong
/font

font size='4' color='#008080'strongThanks for choosing ##hostdomain##
br Any Questions e-mail ##sales##@##hostdomain##/strong /font

/body
/html
;

/* message*/
//$mail_template = $message;

$fullname=Richard Kurth;
 $email=[EMAIL PROTECTED];
 $hostdomain=northwesthost.com;
 $hostname=www;
 $domain=twohot;
  $tld=.com;
 $baseip=234.444.45.444;
 $username=rkurth;
 $password=boat;
 $userdatabase=twohot;
 $newuser=twohot;
 $newuserpass=twohot;
 $sales=sales;
$domainname=$hostname . . . $domain . $tld;


$mail_content = str_replace('##fullname##',$fullname,$mail_template);
$mail_content = str_replace('##email##',$email,$mail_template);
$mail_content = str_replace('##domain##',$domainname,$mail_template);
$mail_content = str_replace('##ip##',$baseip,$mail_template);
$mail_content = str_replace('##username##',$username,$mail_template);
$mail_content = str_replace('##password##',$password,$mail_template);
$mail_content =
str_replace('##userdatabase##',$userdatabase,$mail_template);
$mail_content = str_replace('##newuser##',$newuser,$mail_template);
$mail_content = str_replace('##newuserpass##',$newuserpass,$mail_template);
$mail_content = str_replace('##hostdomain##',$hostdomain,$mail_template);
$mail_content = str_replace('##sales##',$sales,$mail_template);
/* and now mail it */
/* recipients */
$recipient = $fullname $email ;
//header
$headers .=From: Sales Department  [EMAIL PROTECTED] \n;
$headers .= reply-To:$from\nX-Mailer: PHP/ .phpversion(). \n;
$headers .= Content-Type: text/html; charset=iso-8859-1\n;
//subject
$subject1 = $subject;
//mail($recipient, $subject1, $mail_content, $headers);
//print $recipient, $subject1, $mail_content, $headers;
echo $mail_content;











Best regards,
 Richard
mailto:[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] email templates and str_replace

2001-06-20 Thread Brian S. Dunworth



 Richard,
   The problem is with the str_replace()s. Consider the following:
 
 ?php
 $myvar = 'this is a var.';
 $mytext = str_replace('is', 'is not', $myvar);
 ?
 
 At this point $myvar still equals 'this is a var.' but $mytext is 'this is
 not a var.' $myvar hasn't been modfified by the str_replace so any
 additional str_replace()s after it will not have a cumlative effect.

Actually, wouldn't the string then be equal to 'this not is not a var.' ??


- Brian


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]