Why is PHP substituting an underscore in my form?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    Why is PHP substituting an underscore in my form?

    Hi,

    I'm using PHP 4.4.4. I notice for form elements that contain spaces,
    PHP substitutes an underscore for the element name when the form is
    submitted. For example, if I have this page (test.php)

    <html>
    <body onload="documen t.forms[0].submit();">

    <form name="f" action="test_re sponse.php" method="post">
    <input type="hidden" name="Hi There" value="2">
    </form>

    </body>
    </html>

    and then test_response.p hp

    <?php
    foreach (array_keys($_R EQUEST) as $k) {
    $val = $_REQUEST[$k];
    print "key: $k val:$val<BR>\n" ;
    } // foread
    ?>

    the output is

    key: Hi_There val:2
    key: __utma val:171843875.2 38415504.116025 2422.1161727205 .1161788841.6
    key: __utmz
    val:171843875.1 160252422.1.1.u tmccn=(direct)| utmcsr=(direct) |utmcmd=(none)
    key: PHPSESSID val:f8cc02f8aa6 3d9cd7a50e6a1d3 40b1b8

    How do I preserve the space in the element name?

    Thanks, - Dave

  • Andy Hassall

    #2
    Re: Why is PHP substituting an underscore in my form?

    On 5 Nov 2006 20:29:45 -0800, "laredotornado@ zipmail.com"
    <laredotornado@ zipmail.comwrot e:
    >I'm using PHP 4.4.4. I notice for form elements that contain spaces,
    >PHP substitutes an underscore for the element name when the form is
    >submitted. For example, if I have this page (test.php)
    >
    ><html>
    >the output is
    >
    >key: Hi_There val:2
    >key: __utma val:171843875.2 38415504.116025 2422.1161727205 .1161788841.6
    >key: __utmz
    >val:171843875. 1160252422.1.1. utmccn=(direct) |utmcsr=(direct )|utmcmd=(none)
    >key: PHPSESSID val:f8cc02f8aa6 3d9cd7a50e6a1d3 40b1b8
    >
    >How do I preserve the space in the element name?
    Short answer, you can't; longer answer:


    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • Kimmo Laine

      #3
      Re: Why is PHP substituting an underscore in my form?

      <laredotornado@ zipmail.comwrot e in message
      news:1162787385 .554518.319680@ e3g2000cwe.goog legroups.com...
      Hi,
      >
      I'm using PHP 4.4.4. I notice for form elements that contain spaces,
      PHP substitutes an underscore for the element name when the form is
      submitted. For example, if I have this page (test.php)
      Spaces are invalid characters in name attributes. "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
      (".")." (source: <http://www.w3.org/TR/REC-html40/types.html#type-name)

      --
      "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
      http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
      spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


      Comment

      • Andy Hassall

        #4
        Re: Why is PHP substituting an underscore in my form?

        On Mon, 6 Nov 2006 11:35:25 +0200, "Kimmo Laine" <spam@outolempi .netwrote:
        ><laredotornado @zipmail.comwro te in message
        >news:116278738 5.554518.319680 @e3g2000cwe.goo glegroups.com.. .
        >>
        >I'm using PHP 4.4.4. I notice for form elements that contain spaces,
        >PHP substitutes an underscore for the element name when the form is
        >submitted. For example, if I have this page (test.php)
        >
        >Spaces are invalid characters in name attributes. "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
        >(".")." (source: <http://www.w3.org/TR/REC-html40/types.html#type-name)
        Ah, this one again. The name attribute of <inputelement s et. al. are NOT of
        the datatype NAME, they are CDATA, and not subject to these rules.

        If they were, you would not be able to legally use the square bracket suffixes
        that PHP uses when you want the post/get data to come out as an array.

        The restrictions are added by PHP, as historically the register_global s
        behaviour meant that the data was mapped into PHP variables, so the names must
        follow the PHP variable naming scheme, and are mangled by PHP to force them to
        be so if they're not.

        Some previous discussions:





        The only places that NAME is actually used in HTML 4.01 (Transitional) is in
        META for the http-equiv and name attributes, and the lang or hreflang
        attributes on a few other elements.

        --
        Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
        http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

        Comment

        • Kimmo Laine

          #5
          Re: Why is PHP substituting an underscore in my form?

          "Andy Hassall" <andy@andyh.co. ukwrote in message
          news:gjouk2h89a 103m6uhjdcl8rt1 rq97jcd21@4ax.c om...
          On Mon, 6 Nov 2006 11:35:25 +0200, "Kimmo Laine" <spam@outolempi .net>
          wrote:
          >
          >><laredotornad o@zipmail.comwr ote in message
          >>news:11627873 85.554518.31968 0@e3g2000cwe.go oglegroups.com. ..
          >>>
          >>I'm using PHP 4.4.4. I notice for form elements that contain spaces,
          >>PHP substitutes an underscore for the element name when the form is
          >>submitted. For example, if I have this page (test.php)
          >>
          >>Spaces are invalid characters in name attributes. "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
          >>(".")." (source: <http://www.w3.org/TR/REC-html40/types.html#type-name)
          >
          Ah, this one again. The name attribute of <inputelement s et. al. are NOT
          of
          the datatype NAME, they are CDATA, and not subject to these rules.
          Oh my, I was way wrong then. Thank you for correcting me. :)

          --
          "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
          http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
          spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


          Comment

          Working...