Hi,
As a PHP newbie I thought I'd come looking to see if I can pick the brains of some of you coding whiz's out there.
Basically its regarding emails and such.
What I have, is a form to which the user inputs various details, these details then being stored into the db, and then an email sent to the user confirming his actions.
The form, and db insertion work fine.. and I've created the basics of an email routine, as such:
/ if ($insert) {
$challenge2 = mysql_query("SELECT * FROM ccentral_challenges WHERE id=$id",$db);
if ($myrow = mysql_fetch_array($challenge2)) {
echo "<center><table width=\"50%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\">\n";
printf("<tr><td><center><strong>Challenge by %s on behalf of %s has been logged!</strong>", $myrow["ALIAS"], $myrow["CLAN_NAME"]);
$mail_to = ($myrow["EMAIL"]);
$mail_subject = ($myrow["SUBJECT"]);
$mail_body = "Hi ";
$mail_body .= ($myrow["ALIAS"]);
$mail_body .= ",\n";
$mail_body .= "You have recently entered a challenge on the Clan Rage Website\n";
if (mail($mail_to, $mail_subject, $mail_body, "From: challenges@clan-rage.co.uk\r\nReply-to: challenges@clan-rage.co.uk\r\n"))
echo "<br>Sucessfully Sent Email \"$mail_subject\" to $mail_to.</td></tr></table><center>";
else echo "<br>Failed to send Email \"$mail_subject\".</td></tr></table><center>";
exit;
}
}
Now to me this seems like a rather tedious way of doing the email portion of the whole routine. What's more, once Ive finished my scripting, I'm hoping to release it to anyone whom may want to use it. Therefore, it would be nice to be able to edit the format of the email in a nice and easy manner (for example, a .txt file) rather than crawling through all the code to find what need to be altered.
So what I would like to know is, is it possible to maybe use an external file for the mail body (ie a txt file), that can somehow be "merged" with the information contained within the database.
I've tried a couple of ways so far, from including the $myrow["ALIAS"] to assigning variables, and including $variables in the txt. OK, yeah maybe not the brightest of ideas.. but I am a a newbie.. and trying out these kinda things helps me learn.
Anyway, any help on this GREATLY appreciated!
Regards
Lee