Jump to content

Echoing a <textarea>


supertrucker

Recommended Posts

I have a form where a user can type something about themselves. I also have the same issue in a forum I created. The user types a topic/comment into a <textarea>, I use strip_tags() and trim() to clean it up a bit. After that, I submit the data to a SQL table. If I load the SQL data back into a <textarea>, all formatting such as carriage returns are preserved. If I just "echo" it to the screen, all cr's are lost, and everything is printed on one line. If I use the <PRE></PRE> tag, than the formatting is displayed as it should, but no word wrap is used. If I just use <P></P> then nothing is preserved just as a standard echo.Is there a solution to this? There obviously is, as these forums for instance have properly separated these two paragraphs. :)ST

Link to comment
Share on other sites

Try doing this instead:
$chattext = nl2br($chattext);

Thank you, that worked just as well :)
Link to comment
Share on other sites

It seems I somehow posted this exact same post twice! To the forum moderator, the one below this can be removed, my apologies!ST

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...