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. 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); 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; ?> 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. 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. 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
Archived
This topic is now archived and is closed to further replies.