Jump to content

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 recruiter@military.gov.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.