PHP TinyMCE email snaffuu

Attached is a screenshot of an email that's generated from the following code:

$the_name=stripslashes($_POST['name']);
$the_comment = stripslashes($_POST['body']);
$the_comment = str_replace("<P>", "\r\n", "$the_comment");
$the_comment = str_replace("</P>", "", "$the_comment");
$to = "prayer@trinityspringhill.org";
$subject = "prayer request";
$message = "$the_name emailed you with the following prayer request:\n\n$the_comment";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From: prayer@trinityspringhill.org\r\n" ."X-Mailer: php";
 if (!mail($to, $subject, $message, $headers)) {
echo("<p>Message delivery failed...</p>");
}

I'm having a hard time eliminating the <P> garbage. I've tried html_entity_decode and anything else I can think of to no avail.

The tinymce dynamic has been a blessing and a problem in the way it insert line breaks, but surely there's a way to prevent these characters from showing up on the email.

What am I missing?
brucegustPHP DeveloperAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
Try using str_ireplace() which is case in-sensitive instead of str_replace which is case sensitive.
0
 
Ray PaseurConnect With a Mentor Commented:
Consider also strip_tags() and nl2br() -- the answer is in there somewhere if you experiment with the text and the TinyMCE rendering.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.