You are here: How to format text from HTML textarea? « PHP Programming Language « IT news, forums, messages
How to format text from HTML textarea?

Posted by deko on 03/17/07 12:56

I have a feedback form on my website with a textarea for visitors to type
comments, etc. Nothing special. When users click the "Send" button, the form
posts, and I copy the contents of the textarea to a file like this:

$feedback = trim($_POST['feedback_textarea']);
$fp = fopen($feedback_file,'a');
fwrite($fp, $feedback);
fclose($fp);

The problem is the line breaks in the textarea are lost when copied to the file.

For example:

This is a line.

This is a new line.

This is another new line.

becomes:

This is a line. This is a new line. This is another new line.

And this:

This is a "test"

becomes:

This is a \"test\"

Is there a way to preserve line breaks and other formatting when coping to a
file from a HTML textarea?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация