signature16 Posted October 9, 2007 Share Posted October 9, 2007 I have a page with a single textbox and submit button. When the page is processed on itself, it emails somebody the response. When I get the email response, the message submited doesn't include line breaks. How do I add line breaks? You can see in the code below that when $message (its inside $message1) is displayed, it doesn't add the appropriate line breaks if there should be line breaks there. How can I fix that? <?php $submit = $_POST['submit']; $message = $_POST['message']; if( isset($submit) ) { $message1 = "<table width=\"500\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" style=\"border:1px solid #CCCCCC;\"><tbody><tr> <td><img src=\"http://www.theprrt.com/images/email/default-superspine-header.gif\" /></td> </tr><tr><td style=\"padding: 20px 30px; font-size: 10pt; font-family: Arial,Helvetica,sans-serif; line-height: 1.3em; text-align: justify\"> <p> $message </p></td></tr><tr><td><br> <img alt=\"\" src=\"http://www.theprrt.com/images/email/email-footer.gif\"></td></tr></tbody></table> "; $headers = "From: asdf<[email protected]>\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail("[email protected]","Feedback Question 1",$message1,$headers); echo "Thank you for the feedback. If you requested a reply, we will get back to you as soon as possible."; echo "<br />"; echo "$message<br />"; } else{ ?> Link to comment https://forums.phpfreaks.com/topic/72521-solved-add-line-breaks-function/ Share on other sites More sharing options...
pocobueno1388 Posted October 9, 2007 Share Posted October 9, 2007 $message = nl2br($_POST['message']); That should take care of it. Link to comment https://forums.phpfreaks.com/topic/72521-solved-add-line-breaks-function/#findComment-365681 Share on other sites More sharing options...
signature16 Posted October 9, 2007 Author Share Posted October 9, 2007 Its beautiful. Thanks Link to comment https://forums.phpfreaks.com/topic/72521-solved-add-line-breaks-function/#findComment-365685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.