StefanRSA Posted January 13, 2010 Share Posted January 13, 2010 Happy New year Everybody! Back at work and sitting with my hands in my hair. I am trying to build an email template and give the user the abillity to change the template when needed. I have the following variables set in the form that will send the mail: $userresult = mysql_fetch_array($userquery); $name = $userresult['name']; $adusermail = $userresult['email']; $adusername = $userresult['username']; $adusersurname = $userresult['usersurname']; Now I am trying to build a template that the user can change as needed and save it in the "mailtemplate" table in the content column. It might look something like this: Dear <?echo $adusername. ' '.$adusersurname;?> <br> You can email me at: <?echo $adusermail;?><br><br> Thank You!<br> <?echo $name;?> When I echo the content column all is printed but the php script? What am I doing wrong or how should I do it to make it work...? Thanks Link to comment https://forums.phpfreaks.com/topic/188353-store-php-script-in-db-for-template/ Share on other sites More sharing options...
RussellReal Posted January 13, 2010 Share Posted January 13, 2010 why don't you just create pseudo variables.. like.. {name} {email} {age} {sex} etc and just replace those with the variables for example $emailTemplateData = str_replace(array('{name}','{email}','{age}','{sex}'),array($name,$email,$age,$sex),$emailTemplateData); this way your users creating the template just need to draw up the template as follows: Dear {name}, You're now {age} have you ever thought about joining the military? If you are considering it, please send us an email from {email} to our email address [email protected]. Link to comment https://forums.phpfreaks.com/topic/188353-store-php-script-in-db-for-template/#findComment-994330 Share on other sites More sharing options...
StefanRSA Posted January 13, 2010 Author Share Posted January 13, 2010 Great! Thanks Russsel! Wil do just that! THANKS!!!! Link to comment https://forums.phpfreaks.com/topic/188353-store-php-script-in-db-for-template/#findComment-994336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.