I have read through a lot of threads and have found a great deal of information but still having trouble. I want to have a confirmation email sent to people come up in HTML format. I have no problem making regular text come up with HTML attributes but am having no luck with information being retrieved from the Form.
I want the following to have html charteristics:
$message .="First Name: " .$_POST[‘firstname’]
You guys have never let me down. Thanks in Advance.
-wbarrett26
a user will fill out a form putting in thier name and other general info.
a confirmation email is sent to them with the info they submitted.
I can get the general text to come up with html, ie. color size changes, however the fields that are retrieved from the form are only coming up a plain text. I have used a few examples from the forum and other sites as a guide but had no luck.
original confirmation code
function mailuser() {
$to=$_POST['email'];
$subject="Acknowledgement";
$message ="This email confirms your registration."."
";
$message .=""."
";
$message .="First Name: " .$_POST['firstname'] ."
";
$message .="Last Name: " .$_POST['lastname']."
";
$message .="Email Address: " .$_POST['email']."
";
$message .=""."
";
$message .="If there are any errors, please go back to the registration site and re-submit your information."."
";
$headers = "From:". "Registrar";
$headers .= "<registrar@site.com>" ."
";
mail($to, $subject, $message, $headers);
}
?>
new confirmation email, not complete
function mailuser() {
$to=$_POST['email'];
$subject="Acknowledgement";
$message = <<<EOF
<html>
<body bgcolor="#FFFF99" align="center">
<font face="Arial, Helvetica, sans-serif" color="#000099">
This email confirms your registration.<br>
</font>
</body>
</html>
EOF;
$message .="Last Name: " .$_POST['lastname']."
";
$message .="Email Address: " .$_POST['email']."
";
$message .=""."
";
$message .="If there are any errors, please go back to the registration site and re-submit your information."."
";
$headers = "From:". "Registrar";
$headers .= "<registrar@site.com>" ."
";
$headers .= "Content-type: text/html
";
mail($to, $subject, $message, $headers);
}
?>
I would like a way that i could make those POST elements to be in a format other then plain text, either in color or a different font style but when i try to add html code either the POST items would disappear or just not take on HTML styles
Just a guess here, but you have your HTML in the $message variable, which when you originally set it has the opening and closing HTML tags. You then append to the end of that string all the information you want from $_POST. Try putting that infomation inside the start and end HTML tag:
function mailuser() {
$to=$_POST['email'];
$subject="Acknowledgement";
$message = <<<EOF
<html>
<body bgcolor="#FFFF99" align="center">
<font face="Arial, Helvetica, sans-serif" color="#000099">
This email confirms your registration.<br>
EOF;
$message .="Last Name: " .$_POST['lastname']."
";
$message .="Email Address: " .$_POST['email']."
";
$message .=""."
";
$message .="If there are any errors, please go back to the registration site and re-submit your information."."
";
$message .= "
</font>
</body>
</html>";
$headers = "From:". "Registrar";
$headers .= "<registrar@site.com>" ."
";
$headers .= "Content-type: text/html
";
mail($to, $subject, $message, $headers);
}
?>
BTW - I didn’t check the code, you may need to change the "
" to <br> if the "
" is inside the HTML code.
I hadn’t noticed the mail() function was inside a function, probably best practice to actually pass the data to your function like Voccart has shown.
Depending on a number of factors you may be able to call $_POST[] inside a function and get the value stored in the variable. Depends on the set up of your server and registered globals/superglobals (one or both, I forget at the moment :shifty:).