SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    I've created a search form and wanted and want to use a graphic for the submit button, rather than the 'normal submit button'. I've got it to work ok but for some reason I seem to be passing two unwanted variables which I don't want - and don't know where they come from!

    I checked out a few other sites which uses graphics for submit buttons and the same thing happens. The two variables are x & y and there values seem to change at will.

    Whats going on and how can I stop these variables being passed?

    Heres an example of the sort of thing thats happening - seems very strange!!!!!


    http://www.breathe.com/askbreathe/re...x=24&image.y=9

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is because that is how HTTP sends inputs of type image the x and y stand for where the user clicked on the image starting at 0,0 from the upper left hand corner of the image. so if you had this in your form

    <input type="image" name="image" src="blah.gif">

    And the user clicked it then $image.x and $image.y or $image_x and $image_y will get passed on. If you are checking for if ($image) it won't work since the name attribute doesn't get passed with this type of input only the x and y coordinates get passed. Does that help?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks freddy,

    Is this just how PHP acts or doesn't matter what script?

    And I don't think you can access to $image.x ==> parse error
    But $image_x will work just fine, I don't know why!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't think that $image.x worked but in the example link given in an earlier post I saw it that way in the query string, I have always used _x and _y which it turns out thanks to Son is the correct way. It is not a PHP thing it is an HHTP thing.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But why posting through a Perl script, I don't see that encoded in the URL (GET method)?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its kinda weird like that what I have found in php at least if you use the get method with a form with an image input like

    <input type="image" name="submit" src="images/titles/logo.gif">

    After clicking it you will see
    submit.x=34&submit.y=34

    Of course the numbers will change according to where you click the image. IN php you cannot have a variable name with a . in it so if you use _x and _y it somehow magically knows that it is actually .x and .y try it for yourself. Make a form that submits to itself with an image input watch the query string in the location bar of your browser. Then try printing those variables in PHP using _ instead .

    Maybe PERL parses the vars differently but it is all in the POST or GET and it shouldn't matter which scripting langugae you use because the GET and POST strings are the same for all.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •