Page 1 of 1

New line in a text box?

Posted: Wed Feb 11, 2009 7:26 pm
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

Re: New line in a text box?

Posted: Wed Feb 11, 2009 7:38 pm
by John Cartwright
When displaying the content in html, pass it through nl2br()

Re: New line in a text box?

Posted: Wed Feb 11, 2009 7:40 pm
by swraman
Thanks that did it :)