ETA. How do I stop this post from being so wide?
I've been working on a script. A form mail script. A form mail script that I want to write HTML. And I want it to convert tags like <b></b><i></i> into bolds and italics when tags are entered in textarea. So far, so good. But I would also very much like the form to display line breaks that aren't tagged. Meaning that if someone typed in:
Paragraph1
Paragraph2
It would show up like that and not like it is now, like this
Paragraph1Paragraph2
I've tried just about every placing, every variable I could think of to apply but the breaks still won't show in the e-mail I receive.
The current variable story listed within $inside_mail .= nl2br($story); is one of the form textareas, since I gave up on trying to select it for all fields. But nothing works.
Can someone pleas, please help me?
<?
$your_email_addy="you@yourdomain.com";
$your_name="NAME";
$required_fields = explode(",", $required_fields);
for($i = 0; $i < count($required_fields); $i++) {
if($$required_fields[$i] == "") {
print "<html><head><title>$subject</title>";
if($css_file != "")
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">";
print "</head><body bgcolor=$background_color background=$background_image text=$text_color link=$link_color vlink=$visited_link_color alink=$active_link_color><font face=$font_name size=$font_size>The required field <font color=$highlight_color>$required_fields[$i]</font> is empty!";
print "<br><br><a href=\"javascript:history.back(1)\">go back</a></font></body></html>";
exit;
}
}
if($check_email_address == "yes") {
if(!(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email))) {
print "<html><head><title>$subject</title>";
if($css_file != "")
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">";
print "</head><body bgcolor=$background_color background=$background_image text=$text_color link=$link_color vlink=$visited_link_color alink=$active_link_color><font face=$font_name size=$font_size>The email address: <font color=$highlight_color>$email</font> is not valid!";
print "<br><br><a href=\"javascript:history.back(1)\">go back</a></font></body></html>";
exit;
}
}
$fields = array_keys($HTTP_POST_VARS);
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if($actual_var == "required_fields" || $actual_var == "after_url" || $actual_var == "check_email_address" || $actual_var == "subject" || $actual_var == "your_email_addy" || $actual_var == "env_report" || $actual_var == "background_color" || $actual_var == "background_image" || $actual_var == "text_color" || $actual_var == "link_color" || $actual_var == "visited_link_color" || $actual_var == "active_link_color" || $actual_var == "font_name" || $actual_var == "font_size" || $actual_var == "highlight_color" || $actual_var == "css_file" || $actual_var == "owner_name" || $actual_var == "autoresponse" || $actual_var == "response_subject" || $actual_var == "response_mail")
$inside_mail = $inside_mail;
else {
$actual_val = stripslashes($HTTP_POST_VARS[$actual_var]);
$inside_mail.= "$actual_var: $actual_val<br>\n";
}
}
$cname = gethostbyaddr($REMOTE_ADDR);
$inside_mail.=
"
<p>-----------------------------------------------------------------------<br>
SENDER INFO:<br>
IP: $REMOTE_ADDR<br>
Computer Name: $cname<br>
Browser Type: $HTTP_USER_AGENT<br>
Page Referer: $HTTP_REFERER<br>
-----------------------------------------------------------------------
";
$inside_mail .= nl2br($story);
$header = "From: \"".addslashes($name)."\" <".$email.">\r\n";
$header .= "Reply-To: ".$email."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$header .= "X-Priority: 1\r\n";
$header .= "X-Mailer: PHP / ".phpversion()."\r\n";
$header .= "Cc: ".$other_email."\r\n";
$header .= "Bcc: ".$another_email."\r\n";
$success = mail($your_email_addy, $subject, $inside_mail, $header);
if($success) {
if($autoresponse == "yes") {
$response_subject = stripslashes($response_subject);
$response_mail = stripslashes($response_mail);
mail($email, $response_subject, $response_mail, "From: $owner_name <$your_email_addy>");
}
if($after_url == "") {
print "<html><head><title>$subject</title>";
if($css_file != "")
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">";
print "</head><body bgcolor=$background_color background=$background_image text=$text_color link=$link_color vlink=$visited_link_color alink=$active_link_color><font face=$font_name size=$font_size>";
print "The following email has been sent successfully!<br><br><ul>";
for($i = 0; $i < count($fields); $i++) {
$actual_var = $fields[$i];
if($actual_var == "required_fields" || $actual_var == "after_url" || $actual_var == "check_email_address" || $actual_var == "subject" || $actual_var == "your_email_addy" || $actual_var == "env_report" || $actual_var == "background_color" || $actual_var == "background_image" || $actual_var == "text_color" || $actual_var == "link_color" || $actual_var == "visited_link_color" || $actual_var == "active_link_color" || $actual_var == "font_name" || $actual_var == "font_size" || $actual_var == "highlight_color" || $actual_var == "css_file" || $actual_var == "owner_name" || $actual_var == "autoresponse" || $actual_var == "response_subject" || $actual_var == "response_mail")
print "";
else {
$actual_val = stripslashes($HTTP_POST_VARS[$actual_var]);
print "<li>$actual_var: $actual_val<br>";
}
}
print "</ul>PHP formmail powered by form</font></body></html>";
}
} else {
print "<html><head><title>$subject</title>";
if($css_file != "")
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css_file\">";
print "</head><body bgcolor=$background_color background=$background_image text=$text_color link=$link_color vlink=$visited_link_color alink=$active_link_color><font face=$font_name size=$font_size>";
print "An error occured when the form was processed. Please send what you were trying to submit to <a href=\"mailto:$your_email_addy\">$your_name</a> instead.</font></body></html>";
}
?>