Author Topic: Text Field Content Format Retained  (Read 454 times)

royarellano

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Text Field Content Format Retained
« on: August 09, 2010, 12:23:27 PM »
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?
 
Thanks.
 
v/r
Roy

phphelp

  • Administrator
  • Senior Member
  • *****
  • Posts: 777
  • Karma: +3/-0
    • View Profile
    • PHP Help forum
Re: Text Field Content Format Retained
« Reply #1 on: August 09, 2010, 02:03:28 PM »
The solution is simple. Just use textarea in html form like this:

Code: [Select]
<textarea name="content" wrap="soft"><?php echo htmlspecialchars($content?></textarea>

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

Are you experienced in PHP programming and willing to share your knowledge?
Join us at php help forum!

royarellano

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Text Field Content Format Retained
« Reply #2 on: August 10, 2010, 10:12:11 AM »
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.

phphelp

  • Administrator
  • Senior Member
  • *****
  • Posts: 777
  • Karma: +3/-0
    • View Profile
    • PHP Help forum
Re: Text Field Content Format Retained
« Reply #3 on: August 10, 2010, 10:31:50 AM »
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.
Are you experienced in PHP programming and willing to share your knowledge?
Join us at php help forum!

royarellano

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Text Field Content Format Retained
« Reply #4 on: August 10, 2010, 10:41:11 AM »
Make it a PHP page, then?