|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42960 PHP messes up image submit button data
Submitted: 2007-10-14 10:56 UTC Modified: 2021-09-22 13:41 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: efbiaiinzinz at hotmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 5.2.4 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
50 - 31 = ?
Subscribe to this entry?

 [2007-10-14 10:56 UTC] efbiaiinzinz at hotmail dot com
PHP messes up coordinates for <input type="image" .. fields when fieldname is not simple one level name but multilevel name.
For example name="smth[field]" is easy way to test it

Reproduce code:
<form action="" method="GET"><input type="image" name="smth[imgsubmit]" src="t.jpg" width="200" height="200"></form>

Expected result:
Since single level image submits end up in post and get arrays as
fieldname_x and fieldname_y I would expect above code to produce GET array as such:
Array ( [smth] => Array ( [imgsubmit_y] => 80, [imgsubmit_x] => 80 ) )

or even better would be actually
Array ( [smth] => Array ( [imgsubmit] => Array([x] => 80, [y] => 80) ) )

but it woul be a breaking change when changed to that and would be inconsistent with single level fields, but also it would be much clearer and would not prohibit me from having <input type="image" name="someimage" src="..."> and <input type="hidden" name="someimage_x" value="previousvalue"> fields on same form at the same time

Actual result:
Array ( [smth] => Array ( [imgsubmit] => 80 ) )


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-14 12:13 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

See bug#42162
 [2007-10-15 09:53 UTC]
Reopened. This is valid issue. Just not a bug but feature/change request.
 [2011-02-21 20:57 UTC]
-Package: Feature/Change Request +Package: *General Issues -Operating System: Windows XP/Linux +Operating System: *
 [2021-09-13 14:04 UTC] ddpm at liscovius dot de
<div style="display:flex;gap:1em;">
<div>With GET using name[key]:
<form action="" method="GET">
<input type="image" name="smth[imgsubmitget]" alt="imgclick coords using get" src="t.jpg" width="200" height="200"></form>

<div>With GET using name[key][]:
<form action="" method="GET">
<input type="image" name="smth[imgsubmitpost][]" alt="imgclick coords using get (ok)" src="t.jpg" width="200" height="200"></form>

<div>With POST using name[key]:
<form action="<?= basename(__FILE__) ?>" method="POST">
<input type="image" name="smth[imgsubmitpost]" alt="imgclick coords using post" src="t.jpg" width="200" height="200"></form>

<div>With POST using name[key][]:
<form action="<?= basename(__FILE__) ?>" method="POST">
<input type="image" name="smth[imgsubmitpost][]" alt="imgclick coords using post (ok)" src="t.jpg" width="200" height="200"></form>

$_POST: <?php print_r($_POST); ?>
$_GET: <?php print_r($_GET);?>
$_REQUEST: <?php print_r($_REQUEST);?>

name[key]:  browser sends get data: testinputimage.php?smth[imgsubmitget].x=175&smth[imgsubmitget].y=177
name[key][]:browser sends get data: testinputimage.php?smth[imgsubmitpost][].x=65&smth[imgsubmitpost][].y=114

Browser send postdata: smth%5Bimgsubmitpost%5D.x=93&smth%5Bimgsubmitpost%5D.y=88
 [2021-09-13 14:06 UTC] ddpm at liscovius dot de
My previous comment shows a better example to understand the issue.

Using the extra [] seems to be ok as workaround?
 [2021-09-13 14:34 UTC] ddpm at liscovius dot de
What the "living" standard says:
 [2021-09-22 13:41 UTC]
Regarding HTTP, there is nothing special with parameter names
containing brackets or dots.  Regarding HTML forms, for <input
type="image" name="foo"> actually two parameters are sent (foo.x
foo.y).  PHP translates any dots in HTTP parameters to
underscores, and treats bracketed parts as array indexes.
However, it just ignores *any* trailing content after the last
bracket pair.

> Using the extra [] seems to be ok as workaround?

I wouldn't rely on that.  Maybe better don't use arrays for
multiple images, but roll your own treatment.  E.g. use names like
smth_1, smth_2, etc., and scan for these array indexes (smth_1_x,
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 14:01:29 2024 UTC