Jump to content

Store php script in db??? For template???


StefanRSA

Recommended Posts

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

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].

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.