SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: _x variables

  1. #1
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)

    _x variables

    Hello,

    Ever now and again I see an extension to variables '_x'
    e.g. $download_zip_x

    What's it all about?


    Thanks,

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No idea.
    Looks like some convention within the app you're looking at. AFAIK there is no universal meaning for this.

  3. #3
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    I've seen it scattered around the PHP manual - php.net - I'll see if I can find a link.

    --
    IMAGE SUBMIT variable names

    When submitting a form, it is possible to use an image instead of the standard submit button with a tag like:

    Code:
    <input type="image" src="image.gif" name="sub" />
    When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables, sub_x and sub_y. These contain the coordinates of the user click within the image. The experienced may note that the actual variable names sent by the browser contains a period rather than an underscore, but PHP converts the period to an underscore automatically.
    --

    I think the php developer before me was just using it to check that a submit button type='image' has been clicked.

    There's code like this throughout:
    Code:
    if ($download_x > 0) {
      // Download
    }

  4. #4
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, that's a special case for image submit buttons. I haven't come accross it before.
    The $download_x and $download_y will exist if the button was named "download".

    If you have register globals off (you should) then they will be $_POST['download_x'], and not automatically available as normal vars.
    And, yes, it looks like the developer was just testing if the form was submitted.

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    $submitname_y / _x are mouse click coordinates when dealing with image submit buttons.

    It is worth note that IE only sends those coordinates and nothing else when using image submit buttons.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •