PHP control array syntax vs HTML standard

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick Dunford

    PHP control array syntax vs HTML standard

    PHP allows control arrays in forms e.g. this is a counter editing script

    echo "<input name=\"counterd elname[]\" type=\"hidden\" value=\"";

    echo "<input name=\"countern ame[]\" type=\"hidden\"
    value=\"".$name str."\">";

    echo "<input name=\"newvalue[]\" size=".VALUEWID TH."
    value=\"".$valu estr."\">";

    echo "<input name=\"delcount er[".$namestr. "]\" type=\"checkbox \">";

    The resultant web page might look something like this, in part:

    <td><font face="arial,hel vetica" size=2><input
    name="delcounte r[www.mysite.co.n z:]" type="checkbox" ></font></td>
    <tr><td><font face="arial,hel vetica" size=2><input name="counterna me[]"
    type="hidden"
    value="www.mysi te.co.nz:/20040313/index.shtml">www.mysite.co.nz:/20040313
    /index.shtml</font></td>

    Control arrays in PHP offer significant advantages in processing form
    input where there are a variable number of sets of the same elements
    repeated multiple times down the page to allow a set of records of the
    same data fields to be edited. The form elements are received back in the
    processing script as an array which can be dealt with in a
    straightforward for loop.

    According to HTML 4.0 standards, the name of an Input element should
    follow these conventions:

    "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 (".")."

    I don't see anything there about the square brackets which are part of
    the PHP array syntax, but they seem to be accepted and PHP seems to be
    able to turn all the elements it receives into an array on the submission
    of the form to the processing script. Is there something in the CGI
    conventions or HTML that it does permit this syntax?
  • David Dorward

    #2
    Re: PHP control array syntax vs HTML standard

    Patrick Dunford wrote:[color=blue]
    > According to HTML 4.0 standards, the name of an Input element should
    > follow these conventions:
    >
    > "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]

    The name attribute of form controls doesn't actually accept a NAME token as
    its value, it accepts CDATA. For an example of an attribute that takes a
    NAME token, see 'http-equiv'



    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>

    Comment

    • Andy Hassall

      #3
      Re: PHP control array syntax vs HTML standard

      On Tue, 30 Mar 2004 08:42:53 +1200, Patrick Dunford <patrickdunford @nz.invalid>
      wrote:
      [color=blue]
      >PHP allows control arrays in forms e.g. this is a counter editing script
      >
      >The resultant web page might look something like this, in part:
      >
      ><input name="counterna me[]" type="hidden"
      >value="www.mys ite.co.nz:/20040313/index.shtml">
      >
      >According to HTML 4.0 standards, the name of an Input element should
      >follow these conventions:
      >
      >"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 (".")."
      >
      >I don't see anything there about the square brackets which are part of
      >the PHP array syntax, but they seem to be accepted and PHP seems to be
      >able to turn all the elements it receives into an array on the submission
      >of the form to the processing script. Is there something in the CGI
      >conventions or HTML that it does permit this syntax?[/color]

      You've misread the HTML standards; please see some previous discussions:





      The name attribute of the <input> element is not of type NAME, it is of type
      CDATA, and so [ and ] are valid characters within the value of that attribute.

      --
      Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

      Comment

      • Tim

        #4
        Re: PHP control array syntax vs HTML standard

        On Tue, 30 Mar 2004 08:42:53 +1200,
        Patrick Dunford <patrickdunford @nz.invalid> posted:
        [color=blue]
        > www.mysite.co.nz:/20040313[/color]

        This is a most unusual way to specify an address. Why have you put a colon
        there?

        Ordinarily, colons are used in that position to specify a different port to
        use (instead of the standard port 80). e.g. http://www.example.com:8000/

        Cross-posting to so many newsgroups isn't such a brilliant thing to do,
        either.

        --
        If you insist on e-mailing me, use the reply-to address (it's real but
        temporary). But please reply to the group, like you're supposed to.

        This message was sent without a virus, please delete some files yourself.

        Comment

        • Patrick Dunford

          #5
          Re: PHP control array syntax vs HTML standard

          Verily, verily, on Tue, 30 Mar 2004 18:49:25 +0930 in nz.comp article
          <1461y7156xbah$ .1wfdnce223o0q$ .dlg@40tude.net >, Tim
          <tim@mail.local host.invalid> didst uttereth...
          [color=blue]
          > On Tue, 30 Mar 2004 08:42:53 +1200,
          > Patrick Dunford <patrickdunford @nz.invalid> posted:
          >[color=green]
          > > www.mysite.co.nz:/20040313[/color]
          >
          > This is a most unusual way to specify an address. Why have you put a colon
          > there?
          >
          > Ordinarily, colons are used in that position to specify a different port to
          > use (instead of the standard port 80). e.g. http://www.example.com:8000/[/color]

          Colons is a convention in linux programs as a field separator.
          [color=blue]
          >
          > Cross-posting to so many newsgroups isn't such a brilliant thing to do,
          > either.[/color]

          I'm interested in the subject matter not netiquette or political
          correctness dross

          Comment

          • Els

            #6
            Re: PHP control array syntax vs HTML standard

            Patrick Dunford wrote:
            [color=blue][color=green]
            >>Cross-posting to so many newsgroups isn't such a brilliant thing to do,
            >>either.[/color]
            >
            > I'm interested in the subject matter not netiquette or political
            > correctness dross[/color]

            Reminds me of an episide of Spongebob Squarepants, where the
            fish behind the ticket window of the busstation didn't
            understand Spongebob until he used the same language as the
            fish.

            --
            Els

            Sonhos vem. Sonhos vão. O resto é imperfeito.
            - Renato Russo -

            Comment

            • Ulujain

              #7
              Re: PHP control array syntax vs HTML standard

              Patrick Dunford wrote:
              [color=blue]
              >http://www.mysite.co.nz/20040313
              >
              > I'm interested in the subject matter not netiquette or political
              > correctness dross[/color]

              You may be interested to know that URL of yours gives me a 404 error.

              'Later
              Peter

              --
              Peter aka Ulujain - Computing for Fun!

              Comment

              • Neal

                #8
                Re: PHP control array syntax vs HTML standard

                On Tue, 30 Mar 2004 22:25:13 +1200, Patrick Dunford
                <patrickdunford @nz.invalid> wrote:
                [color=blue]
                > I'm interested in the subject matter not netiquette or political
                > correctness dross[/color]

                Then, as this is a free discussion forum, you may feel free to ignore
                those aspects of the thread.

                Comment

                • Tim

                  #9
                  Re: PHP control array syntax vs HTML standard

                  Tim wrote:
                  [color=blue][color=green]
                  >> Cross-posting to so many newsgroups isn't such a brilliant thing to do,
                  >> either.[/color][/color]


                  Patrick Dunford <patrickdunford @nz.invalid> posted:
                  [color=blue]
                  > I'm interested in the subject matter not netiquette or political
                  > correctness dross[/color]

                  When asking for help in the newsgroups, it's generally a good idea not to
                  piss off the people who might just help you. Demonstrating that you're not
                  interested in behaving yourself, and then going further by telling people
                  that you're not interested in behaving yourself, doesn't do anything to
                  help you, either.

                  Cross-posting isn't appreciated, even worse if you don't specify a
                  followup-to (so all replies get directed to one place). It's the sort of
                  thing that gets you instantly ignored by the people who know the most about
                  the problems you're asking about, and getting told not to do it by a lot of
                  other people. Making silly excuses about it just makes you look even
                  stupider.

                  --
                  If you insist on e-mailing me, use the reply-to address (it's real but
                  temporary). But please reply to the group, like you're supposed to.

                  This message was sent without a virus, please delete some files yourself.

                  Comment

                  • Patrick Dunford

                    #10
                    Re: PHP control array syntax vs HTML standard

                    Verily, verily, on Wed, 31 Mar 2004 04:06:43 +0930 in nz.comp article
                    <12rohixnhp52r. x2tpjloldljc$.d lg@40tude.net>, Tim
                    <tim@mail.local host.invalid> didst uttereth...
                    [color=blue]
                    > Tim wrote:
                    >[color=green][color=darkred]
                    > >> Cross-posting to so many newsgroups isn't such a brilliant thing to do,
                    > >> either.[/color][/color]
                    >
                    >
                    > Patrick Dunford <patrickdunford @nz.invalid> posted:
                    >[color=green]
                    > > I'm interested in the subject matter not netiquette or political
                    > > correctness dross[/color]
                    >
                    > When asking for help in the newsgroups, it's generally a good idea not to
                    > piss off the people who might just help you. Demonstrating that you're not
                    > interested in behaving yourself, and then going further by telling people
                    > that you're not interested in behaving yourself, doesn't do anything to
                    > help you, either.[/color]

                    The same applies to people who post time wasting replies.

                    Comment

                    • Neal

                      #11
                      Re: PHP control array syntax vs HTML standard

                      On Wed, 31 Mar 2004 10:16:13 +1200, Patrick Dunford
                      <patrickdunford @nz.invalid> wrote:

                      [color=blue]
                      > The same applies to people who post time wasting replies.[/color]

                      Except that the people writing these replies are the ones you need. You're
                      behaving a little more pompously than someone who wants help normally
                      behaves, and that's not speeding things up any.

                      Comment

                      • Patrick Dunford

                        #12
                        Re: PHP control array syntax vs HTML standard

                        Verily, verily, on Tue, 30 Mar 2004 17:24:40 -0500 in nz.comp article
                        <opr5o4jeu4dvhy ks@news.rcn.com >, Neal <neal413@spamrc n.com> didst
                        uttereth...
                        [color=blue]
                        > On Wed, 31 Mar 2004 10:16:13 +1200, Patrick Dunford
                        > <patrickdunford @nz.invalid> wrote:
                        >
                        >[color=green]
                        > > The same applies to people who post time wasting replies.[/color]
                        >
                        > Except that the people writing these replies are the ones you need. You're
                        > behaving a little more pompously than someone who wants help normally
                        > behaves, and that's not speeding things up any.[/color]

                        There have been in this thread about two useful replies that stuck to the
                        subject.

                        There have been about a dozen time wasting replies.

                        When I post a question, I expect to see reasonable answers, which I got
                        from two or three people. Who told me that the answer was that the
                        attribute was defined in terms of CDATA, which has a different
                        definition.

                        The rest of the people, who post about top posting, spelling, cross
                        posting and other time wasting rants, can just get a life.

                        You may choose to justify your position, the fact of this matter is that
                        I have been reading newsgroups for many years, and have seen many
                        questions asked in computer related groups. The people who have something
                        worthwhile to contribute, and there are many, don't complain about
                        pointless crap like top posting, spelling errors or crossposts to only
                        three groups.

                        But you can guarantee some idiot will always come along and start
                        nitpicking and wasting time over something like that.

                        Comment

                        • Patrick Dunford

                          #13
                          Re: PHP control array syntax vs HTML standard

                          Verily, verily, on Tue, 30 Mar 2004 18:49:25 +0930 in nz.comp article
                          <1461y7156xbah$ .1wfdnce223o0q$ .dlg@40tude.net >, Tim
                          <tim@mail.local host.invalid> didst uttereth...
                          [color=blue]
                          > On Tue, 30 Mar 2004 08:42:53 +1200,
                          > Patrick Dunford <patrickdunford @nz.invalid> posted:
                          >[color=green]
                          > > www.mysite.co.nz:/20040313[/color]
                          >
                          > This is a most unusual way to specify an address. Why have you put a colon
                          > there?
                          >
                          > Ordinarily, colons are used in that position to specify a different port to
                          > use (instead of the standard port 80). e.g. http://www.example.com:8000/[/color]

                          Those are URI specifications. That isn't a URI, if you looked at the spec
                          of the PHP code, it is a countername.

                          Comment

                          • Patrick Dunford

                            #14
                            Re: PHP control array syntax vs HTML standard

                            Verily, verily, on Tue, 30 Mar 2004 17:24:40 -0500 in nz.comp article
                            <opr5o4jeu4dvhy ks@news.rcn.com >, Neal <neal413@spamrc n.com> didst
                            uttereth...
                            [color=blue]
                            > On Wed, 31 Mar 2004 10:16:13 +1200, Patrick Dunford
                            > <patrickdunford @nz.invalid> wrote:
                            >
                            >[color=green]
                            > > The same applies to people who post time wasting replies.[/color]
                            >
                            > Except that the people writing these replies are the ones you need. You're
                            > behaving a little more pompously than someone who wants help normally
                            > behaves, and that's not speeding things up any.[/color]

                            Except that YOU haven't contributed anything worthwhile to this thread so
                            far. You didn't answer my question about PHP, which is what this thread
                            is about.

                            There are two useful answers at the very top of this thread. Neither of
                            them whines about crossposting, spelling, top posting or all the other
                            whinging that happens in newsgroups.

                            The fact is, in some newsgroups there are idiots who waste my time and my
                            bandwidth flaming other people solely on these reasons.

                            Comment

                            • Neal

                              #15
                              Re: PHP control array syntax vs HTML standard

                              On Wed, 31 Mar 2004 12:00:36 +1200, Patrick Dunford
                              <patrickdunford @nz.invalid> wrote:
                              [color=blue]
                              > Except that YOU haven't contributed anything worthwhile to this thread so
                              > far. You didn't answer my question about PHP, which is what this thread
                              > is about.[/color]

                              Well tell you what. You don't want an answer from me, this is not my area.

                              So why am I posting in this thread? Both my previous posts have noted that
                              you're being quite the ass. I'd like to learn more about this myself. If
                              you're going to ignore the well-intentioned criticism of those in this
                              group who can help you, I fear the info you and I want to see won't alight.

                              Two replies could have been more if you hadn't been an ass. I'm simply
                              being honest about this.
                              [color=blue]
                              > There are two useful answers at the very top of this thread. Neither of
                              > them whines about crossposting, spelling, top posting or all the other
                              > whinging that happens in newsgroups.[/color]

                              And your snide responses came after these. Seems you don't plan on being a
                              discussing member of the forum, based on your responses to which we
                              replied. So why are you still here? You got your answers.

                              I don't go out of my way to be rude. I'm a really nice guy. I'm being
                              honest with you. Your responses were totally ignorant of conventions this
                              forum holds to be important. When you devalue them, you devalue US. Think
                              about that.
                              [color=blue]
                              > The fact is, in some newsgroups there are idiots who waste my time and my
                              > bandwidth flaming other people solely on these reasons.[/color]

                              Then don't bait the flames. Read the ng, learn the protocol, and conform.

                              Comment

                              Working...