fanaticTwin fanaticTwin - 9 months ago 49
HTML Question

Sending new line from textarea

I have a form collecting information to be stored in an sql database and displayed on a news feed.

One of the inputs is a text area and I want new lines input by the user to be displayed in the news feed. I'm guessing I want to do the formatting on the output with something like nltobr() and store the info as it's received but the problem is that the input is POSTed with the new lines as nothing but spaces:

<form action="postscript.php" method="post">
<td><label for"content">Content</label></td>
<td><textarea id="content" name="content"></textarea></td>

>>>>>>> array(1) {["content"]=> string(7) "a b c"}

so I guess the thing I want is a way to force the html form to send /r or something similar

Hope you can help, Thanks


The newlines are there. How could var_dump() yield "a b c" with a string length of 7? It's because those white spaces are not spaces but actually newlines, where each white space is 2 characters as \r\n.

Try a string replace of where you echo str_replace("\r\n", "|", $_POST); You will get an output of a|b|c