Re: stripped \n
| From: | Ashley Sheridan | Date: | Wed, 20 Feb 2013 19:20:58 +0000 |
| Subject: | Re: stripped \n | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320268@lists.php.net to get a copy of this message | ||
On Wed, 2013-02-20 at 13:47 -0500, Jim Giner wrote:
> On 2/20/2013 1:32 PM, Matijn Woudt wrote:
> > On Wed, Feb 20, 2013 at 7:16 PM, John Taylor-Johnston <
> > John.Taylor-Johnston@cegepsherbrooke.qc.ca> wrote:
> >
> >> Hi,
> >> I have a <textarea> when submitted creates a new form with the textarea
> >> data in a hidden field:
> >>
> >> <input name="DPRnarration" type="text" hidden
> >> form="DPRform" value="Enter
> >> call
> >>
> >> narration here.">
> >>
> >> But when this new form gets resubmitted, the \n get stripped?
> >>
> >> <input name="DPRnarration" type="text" hidden
> >> form="DPRform" value="Enter
> >> callnarration here.">
> >>
> >> I don't get it.
> >>
> >> There is nothing in my code that is stripping the \n?
> >>
> >> <input name="DPRnarration" type="text" hidden
> >> form="DPRform" value="<?php
> >> echo stripslashes($_POST["**DPRnarration"]);?>">
> >>
> >> Do I need to put it in another textarea and declare it hidden?
> >>
> >
> > An input with type=text is used for single lines, so yes, newlines get
> > stripped.
> > Either use a textarea with style="display: none", or store the data in a
> > session instead.
> >
> > - Matijn
> >
> Actually - an <input type=text> may be intended for single lines, but my
> test shows that it does not drop the \ all by itself.
>
> And actually, the poster's question is very difficult to understand,
> simply because I do believe he doesn't know anything about html or php.
> Probably building something from examples he has seen.
>
> 1 - he doesn't show a <textarea> tag in his examples
> 2 - his sample of his code is such a small fragment we can't tell WHAT
> he is doing.
>
> Most likely the problem is his use of stripslashes in that last code
> line he provided. I wonder if he knows what that does?
>
Also, with the example:
<input name="DPRnarration" type="text" hidden form="DPRform"
value="Enter call
narration here.">
There is no hidden attribute for input elements, and no form attribute
either. If there's a need to stuff elements with extra attributes then
it's best to use data- attributes.
Thanks,
Ash
http://www.ashleysheridan.co.uk