Text Field Content Format Retained

I’d like to create a basic HTML form with a text field where the user can enter content, and retain the format in which the user enters it when saved to the MySQL database. So that when the user views the page and that data content is called from the database its format remains the same with spaces, tabs, new lines for new paragraphs, etc. I don’t need a WYSIWYG editor, I just want to be able to do it from a basic HTML multiple line text box.

Any clues? Anyone?



The solution is simple. Just use textarea in html form like this:

<textarea name="content" wrap="soft"><?php echo htmlspecialchars($content) ?></textarea>

and have value of $content stored in blob/text field type in MySQL database.

Did I do something wrong…LOL? I posted your code into my html page, and the text field appeared and displayed the htmlspecialchars() (the PHP part of your code) in the text field.

Since this is a PHP forum, I assumed that you’re working on php script. If you have this form in static html file, yes - you need to remove php code from it.

Make it a PHP page, then?

Sponsor our Newsletter | Privacy Policy | Terms of Service