| You are here: DEVPPL ‹ Forum ‹ Programming ‹ PHP and MySQL Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
Textarea form element and PHP/MySQL
2 posts
• Page 1 of 1
0
Textarea form element and PHP/MySQL
This is probably a "newbie" question but here it goes: (question first then background)
My questions is whether there is a php or SQL solution to allowing people to input multiple paragraphs in a single "textarea" HTML field and then maintaining those paragraph breaks in the HTML output by my PHP code.
I have created a form that web visitors can fill out. It has the typical one line "input type=text" fields and a "textarea" field. I would like to allow people to put in multiple paragraphs (separated by a blank line) in the textarea field.
When I store the "textarea" content in the MySQL DB and subsequently display it via my PHP script for the world to see, the multiple paragraphs put into the textarea are collapsed into one big paragraph by the normal HTML behavior (because there are no "p" or "br" tags). I tried to use the "PRE" tag to prevent this but then the problem turns into a wrapping issue. I have tried different variations of the "Wrap" attribute to the "textarea" field, but am not happy with the results when compared across the IE, Netscape, Opera, Safari, Windows/Mac browsers.
My questions is whether there is a php or SQL solution to allowing people to input multiple paragraphs in a single "textarea" HTML field and then maintaining those paragraph breaks in the HTML output by my PHP code.
I have created a form that web visitors can fill out. It has the typical one line "input type=text" fields and a "textarea" field. I would like to allow people to put in multiple paragraphs (separated by a blank line) in the textarea field.
When I store the "textarea" content in the MySQL DB and subsequently display it via my PHP script for the world to see, the multiple paragraphs put into the textarea are collapsed into one big paragraph by the normal HTML behavior (because there are no "p" or "br" tags). I tried to use the "PRE" tag to prevent this but then the problem turns into a wrapping issue. I have tried different variations of the "Wrap" attribute to the "textarea" field, but am not happy with the results when compared across the IE, Netscape, Opera, Safari, Windows/Mac browsers.
- Mneder
- Reputation: 0
- Posts: 1
- Joined: Thu Oct 14, 2004 5:55 pm
- Location: Mountain View, CA
- Highscores: 0
- Arcade winning challenges: 0
Textarea form element and PHP/MySQL - Sponsored results
- Sponsored results
0
Once you have submitted the forum pass the variable through nl2br to have line breaks entered as HTML.
Like:
Also, make the forms method=post:
Using post as the forms method allows the data not only to be secure but also allows you to have a larger text lenght.
Hope that helps
Like:
- Code: Select all
$ktextarea_input = nl3br($_POST['textarea']);
Also, make the forms method=post:
- Code: Select all
<form name="form1" action="page2.php" method="post">
Using post as the forms method allows the data not only to be secure but also allows you to have a larger text lenght.
Hope that helps

- Malcolm
- Reputation: 0
- Posts: 198
- Joined: Thu Oct 07, 2004 10:53 pm
- Location: Ontario, Canada
- Highscores: 0
- Arcade winning challenges: 0
|
|