Posted by Justin Koivisto on 10/11/05 14:51
Robizzle wrote:
<snip>
NC answered your first question well, so no reason for me to suggest the
same thing here.
> And if you guys don't mind I have another simple question that I dont
> feel deserves its own topic. In relation to this...
> I have the following code in makenews.html
> Enter Body:<br><textarea name="body" cols=30 rows=10></textarea>
> Which works fine except that any new lines that are entered in this
> text area are omitted in $_POST["body"]. If I physically type a <p> or
> <br> tag into the textarea it gets properly interpreted but I know
> there has to be another way. For example as i'm typing right now, I
> could hit enter a few times and it will be recorded and transferred
> into my topic. What are the escape characters for a new line in a php
> string and what can I do about this?
For the text that is posted from the textarea, the newline characters
are submitted. Your problem is that you simply echo the result. The
thing to remember is that a textarea field acts just like plain text.
When it is rendered in the browser, the whitespace like new lines are
replaced with a single space. Try using nlbr($_POST['body']) which will
add <br /> tags with your newline characters for a (more) proper HTML
display.
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|