|
Posted by Daz on 01/14/07 03:07
On Jan 13, 10:49 pm, "ghostwalker" <m...@weblogica.co.uk> wrote:
> Hi
>
> I have an HTML form with a textarea on it. When submitted (using 'get'
> not 'post') this forms action php file simply does this to retrieve the
> values:
>
> $message = $_GET["message"];
>
> Now it all works fine but I get the string in one long string with no
> '\n' where the user pressed 'return key'
>
> How can I get the carriage returns in the textarea to be replaced with
> a '\n' ??? Its driving me nuts here!!
Is there any particular reason that you aren't using POST? Generally,
GET is for getting data, and POST is for posting. Also, I believe that
post encodes and escapes the data, too, so it will arrive as you'd
expect it to. My guess is that there is not URL code for the newline
chracter, as it's a control code, and not meant to be visible.
Also, retrieving the contents of a text area through GET could make for
a _BIG_ URL. I would recommend you use POST for forms, unless they are
seriously limited text input fields (with no special characters/control
codes). Also, what would happen when the GET URL has been submitted,
and the user hits refresh immediately after? The form data would be
submitted again. If you'd used post, the user would have to go back a
page and refresh in order to resubmit the form, and even then, most, if
not all browsers, will alert the user that they are about to repost
data that's already been posted.
I hope this helps.
Daz.
Navigation:
[Reply to this message]
|