SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic Image Map Question

    I have the following on a page called rate.php:

    <form action="rate.php" method="post">
    <input type="image" name="rating" src="meter.gif" ISMAP />
    </form>

    At the top of the page, I have the following function:

    Code:
    function displayRating()
    {
    	if (isset($_POST["rating.x"]))
    	{
    		$meter = $_POST["rating.x"];
    		
    		print $meter;
    	}
    }
    When I print displayRating() in the body of the page, nothing is displayed. I can see that $_POST["rating.x"] is not correct, so what is?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    print_r($_POST) to see all variables sent to your script. I would test this in several browsers as they may handle your image input differently.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in post get cookie, php always converts . to _ in array keys, so rating_x

    if possible i would recomend adding a hidden field to your form, and use that to test for form submission.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by clamcrusher
    and use that to test for form submission.
    What he's doing is not testing for form submission, it's recording where the user clicked on an image of a meter. A graphical rating system.

  5. #5
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan Grossman, and to do that, you need to test for form submission before getting data from the submission (the coordinates).

    clamcrusher is right, the variables are rating_x and rating_y


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
  •