I'm not too sure on what to do.

Hello all!

I have written a script that emails my clients. The program loads standard html and css. Here is how it works:

[php] session_start();
if ($_POST[‘Submit’] == ‘Send Warning’) {
if (strcmp(md5($_POST[‘user_code’]), $_SESSION[‘ckey’])) {
header(“Location: sendmail.php?msg=0”);
exit();
}
$to = $_POST[‘toemail’];
if ($_POST[‘Submit’] == ‘Send’) {
$subject = “New Email!”;
$message = "

body { background-color: #EBEBEB; }[/php]

And so on.

I want to be able to select multiple email “templates”. So my question is, how would I be able load externally instead of drawing straight from the $message = “…”
I want to have multiple email templates and be able to access them.

I will post any code if necessary.

Well, there are many ways to do this. You could create the templates and save in text files or save in a database and pull them as needed. You could just load them into a text variable. Basically, you just encode them with some values for each area such as name, address, etc and use special formats for them… Something like these: -->name<–, -->address<-- … So, then, you would just replace these with your real data. Let’s say the name is inside variable " $name “, and the entire template is in variable " $template “, you could do this type of convert: $message = str_replace(”–>name<–”, $name, $template);
So, as an example: Dear -->name<–,
How are you would become Dear John,
How are you…

Something like that would work and you would just repeat a list of str_replace()'s for each item…

Hope that idea helps you out… Good luck!

That was exactly what I was looking for. Thank you so much, ErnieAlex! Cheers

Glad I could help! There are always tons of ways to do programming, but, sometimes it just takes a step back or a friendly suggestion… Good luck with your project! CYA in the bitstream…

Sponsor our Newsletter | Privacy Policy | Terms of Service