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

Use fgets()?Reads a file line by line. Like this:

<textarea><?php$file = fopen("test.txt","r");while(! feof($file))  {  echo fgets($file). "<br />";  }fclose($file);?></textarea>

Something like that?

Link to comment
Share on other sites

i know what ur talking about supertruckeri had that problem to but i solved it by saving the textarea with nothing no trim() etc...just save the raw input then create your own function to clean it i have and never have i had a problem scince!

Link to comment
Share on other sites

i know what ur talking about supertruckeri had that problem to but i solved it by saving the textarea with nothing no trim() etc...just save the raw input then create your own function to clean it i have and never have i had a problem scince! only clean the function on output though not when ur saving it! Edit: woops was supposed to edit the other post not reply to it! lol

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...