emvy03 Posted September 18, 2011 Share Posted September 18, 2011 Hi, I'm not sure if this should be in PHP or HTML so apologies if it's in the wrong area. I have a form with a text area element but when the text is submitted, tags such as <br> aren't included so the outputted text is never formatted correctly such as there being no paragraphs. Is there a way make sure such tags are included in the output text? Ta. Quote Link to comment https://forums.phpfreaks.com/topic/247372-including-tags-in-a-text-area/ Share on other sites More sharing options...
$php_mysql$ Posted September 18, 2011 Share Posted September 18, 2011 solution is nl2br($str); Quote Link to comment https://forums.phpfreaks.com/topic/247372-including-tags-in-a-text-area/#findComment-1270403 Share on other sites More sharing options...
emvy03 Posted September 19, 2011 Author Share Posted September 19, 2011 Thanks. It processes the code to include line breaks but its just not displaying the code to include the breaks. I.e. If I have text like: Roses are red, Violets are blue The page displays: Roses are red, Violets are blue This is the code to display the text ($msg is the php variable for the text): <?php echo '<div style="margin-top:5px; margin-left: 15px;float:left; font-size:12px; font-weight:bold;">' . $date_added . '</div><br><h4>' . $title . '</h4>' . $msg; ?> Quote Link to comment https://forums.phpfreaks.com/topic/247372-including-tags-in-a-text-area/#findComment-1270676 Share on other sites More sharing options...
ManiacDan Posted September 19, 2011 Share Posted September 19, 2011 And...have you used nl2br anywhere? I don't see it. Quote Link to comment https://forums.phpfreaks.com/topic/247372-including-tags-in-a-text-area/#findComment-1270695 Share on other sites More sharing options...
emvy03 Posted September 19, 2011 Author Share Posted September 19, 2011 Sorry, I placed the 'nl2br' in the wrong place. Thanks for pointing it out. All is good now. Ta. Quote Link to comment https://forums.phpfreaks.com/topic/247372-including-tags-in-a-text-area/#findComment-1270704 Share on other sites More sharing options...
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.