New line in a text box?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

New line in a text box?

Post by swraman »

Hi,

Im writing a script that uses text boxes that users can submit text in.

The problem is, when you push enter (for a new line) in the text box, what appears as a new line in the text box gets sent to PHP as a space.

How do you differenciate between spaces and new lines? I dont want the user to have to type in /r/n or push a button each time they want to go to the next line; it should be like it is here and on other forums where the enter key
moves you to the next line.

How do I work around this?

Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: New line in a text box?

Post by John Cartwright »

When displaying the content in html, pass it through nl2br()
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: New line in a text box?

Post by swraman »

Thanks that did it :)
Post Reply