Posting name="abc def"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jochen Daum

    Posting name="abc def"

    Hi !

    If I have an input field

    <form ... method="post">

    <input type="text" name="abc def">

    </form>

    It always comes through as

    $_POST["abc_def"]

    I tried urlencode and rawurlencode and can't quite understand why it
    is changed somwhere.

    Converting " " to "_" is not quite what I want, because it should be
    working with generated field names.

    Any ideas?

    Jochen


    --
    Jochen Daum - CANS Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

  • Agelmar

    #2
    Re: Posting name=&quot;abc def&quot;

    Jochen Daum wrote:[color=blue]
    > Hi !
    >
    > If I have an input field
    >
    > <form ... method="post">
    >
    > <input type="text" name="abc def">
    >
    > </form>
    >
    > It always comes through as
    >
    > $_POST["abc_def"]
    >
    > I tried urlencode and rawurlencode and can't quite understand why it
    > is changed somwhere.
    >
    > Converting " " to "_" is not quite what I want, because it should be
    > working with generated field names.
    >
    > Any ideas?
    >
    > Jochen[/color]

    Yes. Use valid HTML.

    Read the HTML 4.01 spec, specifically section 6.2:
    (http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)

    To make it painfully obvious:
    "ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
    by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
    colons (":"), and periods ("."). "

    A space is not valid inside of a name. Therefore, you should be happy that
    PHP accepts it at all. (It may actually be the browser that's changing it
    too, I'm not sure... the behaviour is undefined since it's not valid HTML.)


    Comment

    • Jochen Daum

      #3
      Re: Posting name=&quot;abc def&quot;

      Hi Agelmar!

      On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
      <ifetteNOSPAM@c omcast.net> wrote:
      [color=blue]
      >Jochen Daum wrote:[color=green]
      >> Hi !
      >>
      >> If I have an input field
      >>
      >> <form ... method="post">
      >>
      >> <input type="text" name="abc def">
      >>
      >> </form>
      >>
      >> It always comes through as
      >>
      >> $_POST["abc_def"]
      >>
      >> I tried urlencode and rawurlencode and can't quite understand why it
      >> is changed somwhere.
      >>
      >> Converting " " to "_" is not quite what I want, because it should be
      >> working with generated field names.
      >>
      >> Any ideas?
      >>
      >> Jochen[/color]
      >
      >Yes. Use valid HTML.
      >
      >Read the HTML 4.01 spec, specifically section 6.2:
      >(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)
      >
      >To make it painfully obvious:
      >"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
      >by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
      >colons (":"), and periods ("."). "[/color]

      Ok, I solved it by using

      name="name[keyfield1;keyfi eld2]"

      which at least works with spaces. Not a good idea I know.

      However, . is turned into underscore by PHP, though its valid HTML
      obviously. Just wondered, why this is.

      Jochen
      [color=blue]
      >
      >A space is not valid inside of a name. Therefore, you should be happy that
      >PHP accepts it at all. (It may actually be the browser that's changing it
      >too, I'm not sure... the behaviour is undefined since it's not valid HTML.)
      >[/color]

      --
      Jochen Daum - CANS Ltd.
      PHP DB Edit Toolkit -- PHP scripts for building
      database editing interfaces.
      Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

      Comment

      • Andy Hassall

        #4
        Re: Posting name=&quot;abc def&quot;

        On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
        <ifetteNOSPAM@c omcast.net> wrote:
        [color=blue]
        >Jochen Daum wrote:[color=green]
        >> If I have an input field
        >>
        >> <form ... method="post">
        >>
        >> <input type="text" name="abc def">
        >>
        >> </form>
        >>
        >> It always comes through as
        >>
        >> $_POST["abc_def"]
        >>
        >> I tried urlencode and rawurlencode and can't quite understand why it
        >> is changed somwhere.
        >>
        >> Converting " " to "_" is not quite what I want, because it should be
        >> working with generated field names.
        >>
        >> Any ideas?
        >>
        >> Jochen[/color]
        >
        >Yes. Use valid HTML.[/color]

        The above is valid HTML.
        [color=blue]
        >Read the HTML 4.01 spec, specifically section 6.2:
        >(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)
        >
        >To make it painfully obvious:
        >"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
        >by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
        >colons (":"), and periods ("."). "
        >
        >A space is not valid inside of a name. Therefore, you should be happy that
        >PHP accepts it at all. (It may actually be the browser that's changing it
        >too, I'm not sure... the behaviour is undefined since it's not valid HTML.)[/color]

        The name attribute of the INPUT element is defined in the HTML DTD to
        be of type CDATA, not of the restricted types ID or NAME.

        There are no further restrictions on the values of the INPUT name
        attribute listed in the specification.

        See:



        ... starting with David K. Wall's post that made the same assertion,
        and read mine and Tad McLellan's replies.

        PHP applies its own restrictions on accepted values of the name
        attribute, presumably inherited from the register_global s=on days;
        names are restricted to those that are valid for PHP variable names,
        and are rewritten using underscores for invalid characters.

        Comment

        • Agelmar

          #5
          Re: Posting name=&quot;abc def&quot;

          Agelmar wrote:[color=blue]
          > Jochen Daum wrote:[color=green]
          >> Hi Agelmar!
          >>
          >> On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
          >> <ifetteNOSPAM@c omcast.net> wrote:
          >>[color=darkred]
          >>> Jochen Daum wrote:
          >>>> Hi !
          >>>>
          >>>> If I have an input field
          >>>>
          >>>> <form ... method="post">
          >>>>
          >>>> <input type="text" name="abc def">
          >>>>
          >>>> </form>
          >>>>
          >>>> It always comes through as
          >>>>
          >>>> $_POST["abc_def"]
          >>>>
          >>>> I tried urlencode and rawurlencode and can't quite understand why
          >>>> it is changed somwhere.
          >>>>
          >>>> Converting " " to "_" is not quite what I want, because it should
          >>>> be working with generated field names.
          >>>>
          >>>> Any ideas?
          >>>>
          >>>> Jochen
          >>>
          >>> Yes. Use valid HTML.
          >>>
          >>> Read the HTML 4.01 spec, specifically section 6.2:
          >>> (http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)
          >>>
          >>> To make it painfully obvious:
          >>> "ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
          >>> followed by any number of letters, digits ([0-9]), hyphens ("-"),
          >>> underscores ("_"), colons (":"), and periods ("."). "[/color]
          >>
          >> Ok, I solved it by using
          >>
          >> name="name[keyfield1;keyfi eld2]"
          >>
          >> which at least works with spaces. Not a good idea I know.
          >>
          >> However, . is turned into underscore by PHP, though its valid HTML
          >> obviously. Just wondered, why this is.
          >>
          >> Jochen[/color]
          >
          > No, it is not valid HTML. You are using a semicolon. This is not
          > valid. You can only use letters, numbers, hyphens, underscores,
          > colons, and periods. You may *not* use a semicolon. Did you even read
          > what I posted?[/color]

          Hmm, nevermind, it seems as if I am incorrect. Read Andy's post for more
          information.

          Sorry.


          Comment

          • Agelmar

            #6
            Re: Posting name=&quot;abc def&quot;

            Andy Hassall wrote:[color=blue]
            > On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
            > <ifetteNOSPAM@c omcast.net> wrote:
            >[color=green]
            >> Jochen Daum wrote:[color=darkred]
            >>> If I have an input field
            >>>
            >>> <form ... method="post">
            >>>
            >>> <input type="text" name="abc def">
            >>>
            >>> </form>
            >>>
            >>> It always comes through as
            >>>
            >>> $_POST["abc_def"]
            >>>
            >>> I tried urlencode and rawurlencode and can't quite understand why it
            >>> is changed somwhere.
            >>>
            >>> Converting " " to "_" is not quite what I want, because it should be
            >>> working with generated field names.
            >>>
            >>> Any ideas?
            >>>
            >>> Jochen[/color]
            >>
            >> Yes. Use valid HTML.[/color]
            >
            > The above is valid HTML.
            >[color=green]
            >> Read the HTML 4.01 spec, specifically section 6.2:
            >> (http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)
            >>
            >> To make it painfully obvious:
            >> "ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
            >> followed
            >> by any number of letters, digits ([0-9]), hyphens ("-"), underscores
            >> ("_"),
            >> colons (":"), and periods ("."). "
            >>
            >> A space is not valid inside of a name. Therefore, you should be
            >> happy that
            >> PHP accepts it at all. (It may actually be the browser that's
            >> changing it
            >> too, I'm not sure... the behaviour is undefined since it's not valid
            >> HTML.)[/color]
            >
            > The name attribute of the INPUT element is defined in the HTML DTD to
            > be of type CDATA, not of the restricted types ID or NAME.
            >
            > There are no further restrictions on the values of the INPUT name
            > attribute listed in the specification.
            >
            > See:
            >
            >[/color]
            http://groups.google.com/groups?hl=e...3.30&frame=off[color=blue]
            >
            > ... starting with David K. Wall's post that made the same assertion,
            > and read mine and Tad McLellan's replies.
            >
            > PHP applies its own restrictions on accepted values of the name
            > attribute, presumably inherited from the register_global s=on days;
            > names are restricted to those that are valid for PHP variable names,
            > and are rewritten using underscores for invalid characters.[/color]

            Hmm... interesting. Good to know. Personally though, I'll stick with names
            valid in C :-)

            Sorry to the original poster for my incorrect reply.


            Comment

            • David Robley

              #7
              Re: Posting name=&quot;abc def&quot;

              In article <o28mjvkdp7g1vf m82s8ma8itfa9m3 e1t45@4ax.com>,
              jochen.daum@can s.co.nz says...[color=blue]
              > Hi Agelmar!
              >
              > On Thu, 14 Aug 2003 01:25:55 -0400, "Agelmar"
              > <ifetteNOSPAM@c omcast.net> wrote:
              >[color=green]
              > >Jochen Daum wrote:[color=darkred]
              > >> Hi !
              > >>
              > >> If I have an input field
              > >>
              > >> <form ... method="post">
              > >>
              > >> <input type="text" name="abc def">
              > >>
              > >> </form>
              > >>
              > >> It always comes through as
              > >>
              > >> $_POST["abc_def"]
              > >>
              > >> I tried urlencode and rawurlencode and can't quite understand why it
              > >> is changed somwhere.
              > >>
              > >> Converting " " to "_" is not quite what I want, because it should be
              > >> working with generated field names.
              > >>
              > >> Any ideas?
              > >>
              > >> Jochen[/color]
              > >
              > >Yes. Use valid HTML.
              > >
              > >Read the HTML 4.01 spec, specifically section 6.2:
              > >(http://www.w3.org/TR/1999/REC-html40...tml#type-cdata)
              > >
              > >To make it painfully obvious:
              > >"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
              > >by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
              > >colons (":"), and periods ("."). "[/color]
              >
              > Ok, I solved it by using
              >
              > name="name[keyfield1;keyfi eld2]"
              >
              > which at least works with spaces. Not a good idea I know.
              >
              > However, . is turned into underscore by PHP, though its valid HTML
              > obviously. Just wondered, why this is.
              >
              > Jochen
              >[color=green]
              > >
              > >A space is not valid inside of a name. Therefore, you should be happy that
              > >PHP accepts it at all. (It may actually be the browser that's changing it
              > >too, I'm not sure... the behaviour is undefined since it's not valid HTML.)
              > >[/color]
              >
              >[/color]

              Well, the . is the concatenation operator in PHP, so they need to be
              changed to something that is valid in a PHP variable name.

              --
              Quod subigo farinam

              $email =~ s/oz$/au/o;
              A: Because it messes up the order in which people normally read text.
              Q: Why is top-posting such a bad thing?
              A: Top-posting.
              Q: What is the most annoying thing on usenet?

              Comment

              Working...