Hillbilly 0 Posted November 5, 2018 Report Share Posted November 5, 2018 I am sure this is a stupid question but I'm tearing my hair out. I am trying to email data that I have cleaned (from a multi-line text box) with escape_data. The problem is the data is sent with \r\n instead of actual line breaks. Eg: message in email will read "Hello\r\nThis is the 1st parapgraph\r\n\r\nThis is another" I have tried to remedy this below but it does not work: if ($_POST['Information'] != '') { $Information = escape_data($_POST['Information'], $dbc); $Informationformatted = str_replace(array("\r\n", "\r", "\n"), "<br />", $Information); } else { $contact_errors['Information'] = 'Please enter your message'; } //message in email $body = $Informationformatted; $headers = 'MIME-Version: 1.0'. "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n"; $headers .= 'From:'.$Email; mail ('email@email.com', 'Message', $body, $headers); I am still getting the same output: "Hello\r\nThis is the 1st parapgraph\r\n\r\nThis is another" I have also tried $Informationformatted = nl2br($Information); This did not work either. (Or would be something to do with the headers?) Quote Link to post Share on other sites
Larry 429 Posted November 5, 2018 Report Share Posted November 5, 2018 You're running the values through escape_data(), which probably means that the incoming \n (for example) gets turned into \\n which is why nothing else works from there on. And I would just use nl2br() instead of str_replace(). Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.