Dynadot โ€” .com Registration $8.99

PHP help.

Spaceship Spaceship
Watch

TwiztedFake

Established Member
Impact
1
How do I insert line breaks into a text area form input when a users hits the enter to start a new line.

The form is submited via PHP to be stored in a database. Everything works fine just needing to know how to insert the line breaks.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
cant you do '/n' or something
 
0
•••
\r\n
 
0
•••
If you're talking how to show 'Enters' submitted by a form into pure HTML, use the php function nl2br:

PHP:
$str = $user_submitted_thing_with_line_breaks;
$new_str = nl2br($str);

It will make all line breaks into <br />'s
 
0
•••
presumably you are having problems of the text only showing on 1 line when you rtetrieve it back from the database.

If that is the case run the variable through nl2br(). This changes the new line char to the <br> which html needs.
 
0
•••
It depends what you want to do with the results from the textarea. If you wish to display it as text either nl2br or wordwrap will work. If you wish to store it in mysql db I would probley use nl2br. If you don't need to do anything but store it to be used in another textarea nothing is needed.

iNod.
 
0
•••
Thanks everyone I used nl2br() and it works just how I wanted. I store the information in the database then it is displayed on a page at a later time.

I gave everyone 10 np's for helping.
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back