Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

PHP help.

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
cant you do '/n' or something
 
0
Close
\r\n
 
0
Close
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
Close
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
Close
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
Close
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
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back