I have text area and when the user submit the form I save the data into my db in db the line breaks work excellently but when displaying them back with echo the line breaks disappear :( I check all things and removed all validation functions like strip_tags and so on just printed it pure from db but the same thing so can anyone tell me what went wrong ? thnx in advance
Line breaks in textarea
is while for browsers it's just white-space. You need to replace them with
<br />
tag. php took care of it and you have nl2br
function for that:
echo nl2br($stringFromDB);
Note: when you output user-input always escape it at first. So basically you should be doing:
// Chaining functions like this is bad. Avoid in real world apps.
echo nl2br(htmlspecialchars($stringFromDB, ENT_QUOTES, 'UTF-8'));