Good Day,
I have got a problem with my script. What I'm doing is:
I want to send an email to user. There are different templates for different type of mails like one design for SignUp confirmation, one for recent news etc. So, what I did is, I created a table and stored each design in column called content with its complete HTML code.
My database design is pretty simple for this purpose:
ID | type | content
1 | signup | <html> ... <body> .. content of email ... </body></html>
So, right above is my database. field with ID 1 Now, when someone signs up, I am trying to send him an email whose content is fetched from table above. Text under content field is like:
<html>
.
.
<body>
Good Day,
You have successfully created your account.
Please activate your account now by clicking below:
<a href="activate.php?md5=$md5&code=$code">ACTIVATE</a>
</body>
</html>
In above code, if you checkout the activate link, I have used PHP variables $md5 and $code, thinking that their corresponding values would be printed in actual email. But they are printed as it is, like $md5 and $code.
Well, I did little research and from few forums, I got to know that,
1st: While we added content of HTML template to database along with these PHP variables, they have become a value of that database column itself and would not be treated as PHP variables anymore.
2nd: One person claims that he have made it's working using eval() function. I can use eval since, im not taking any value from user but database, from point of security. I tried it, but still nothing.
Below is code which I tried with eval():
$md5 = $row['md5']; // These variables values I'm expecting to come in template content
$code = $row['activ_code']; // These variables values I'm expecting to come in template content
ob_start();
eval("\$template_content = \"$template_content\";");
$message = $template_content;
ob_end_clean();
Can someone help me out with this? I don't want to put complete template (HTML) on the same page where I'm using the mail function. It makes code look ugly instead of keeping it short and neat.
Please help!