By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,203 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,203 IT Pros & Developers. It's quick & easy.

input type="image" $_POST queries

P: n/a
Hi all,

I'm trying to set up a 'control panel' consisting of a table of icons.

The early stages: http://www.deepinit.com/controlcentre.php

Each of these is set up like:

<td>
<input type="image" id="addnews" src="/Image/add24.png"
name="addnews" value="addnews" width="24" height="24"><br />
<label for="addnews">Add News Item</label><br />
</td>

This is all taking place in a html form and I'm using input
type="image"... like 'submit' buttons.

Is this a 'good' approach?

I'm trying to handle the $_POST variable after a user clicks on one of
these but there are differences between firefox and ie6.

Using:
foreach ($_POST as $key=>$val) {
echo $key ."|". $val . "<br />";
}

ie6 is only listing
addnews_x|8
addnews_y|17
Firefox:
addnews_x|10
addnews_y|13
addnews|addnews

Why am I getting x and y co-ordinates?

Why in firefox do I get $val ('addnews|addnews') but not in ie6?

What I'm trying to do is redirect to other pages based on $_POST:

foreach ($_POST as $key=>$val) {
switch (strtolower($key)) {
case 'addnews_x':
PostHandler('addnews', 'news', '/posteditor.php');
break;
case 'editnews_x':
PostHandler('editnews', 'news', '/postsearch.php');
break;
case 'deletenews_x':
PostHandler('deletenews', 'news', '/postsearch.php');
break;
...

function PostHandler($command, $post_type, $redir_page) {
$_SESSION['ctlcentcmd'] = $command;
$_SESSION['posttype'] = $post_type;

ob_end_clean();
header('Location: http://' . $_SERVER['HTTP_HOST']
. $redir_page);
}
This is working but I'm not happy basing this on the x co-ordinate
(eg addnews_x). Surely there must be a better way?

If you wanted to implement a similar icon based 'Control Centre' what
approach would you take? The intent is to have a single page where the
site admin can add/edit/delete news, articles, bios, user data, etc
thanks for your help,

--
Mark

Jul 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Since your using an image in an input field then that information is
being submitted by post to (the image is). Thats fine, just access each
post variable indivually (yes it takes a bit longer but as you have
seen IE and FF differ)

so just get your vars as so: $submitedname = $_POST['name'];

Flamer.

Mark Woodward wrote:
Hi all,

I'm trying to set up a 'control panel' consisting of a table of icons.

The early stages: http://www.deepinit.com/controlcentre.php

Each of these is set up like:

<td>
<input type="image" id="addnews" src="/Image/add24.png"
name="addnews" value="addnews" width="24" height="24"><br />
<label for="addnews">Add News Item</label><br />
</td>

This is all taking place in a html form and I'm using input
type="image"... like 'submit' buttons.

Is this a 'good' approach?

I'm trying to handle the $_POST variable after a user clicks on one of
these but there are differences between firefox and ie6.

Using:
foreach ($_POST as $key=>$val) {
echo $key ."|". $val . "<br />";
}

ie6 is only listing
addnews_x|8
addnews_y|17
Firefox:
addnews_x|10
addnews_y|13
addnews|addnews

Why am I getting x and y co-ordinates?

Why in firefox do I get $val ('addnews|addnews') but not in ie6?

What I'm trying to do is redirect to other pages based on $_POST:

foreach ($_POST as $key=>$val) {
switch (strtolower($key)) {
case 'addnews_x':
PostHandler('addnews', 'news', '/posteditor.php');
break;
case 'editnews_x':
PostHandler('editnews', 'news', '/postsearch.php');
break;
case 'deletenews_x':
PostHandler('deletenews', 'news', '/postsearch.php');
break;
...

function PostHandler($command, $post_type, $redir_page) {
$_SESSION['ctlcentcmd'] = $command;
$_SESSION['posttype'] = $post_type;

ob_end_clean();
header('Location: http://' . $_SERVER['HTTP_HOST']
. $redir_page);
}
This is working but I'm not happy basing this on the x co-ordinate
(eg addnews_x). Surely there must be a better way?

If you wanted to implement a similar icon based 'Control Centre' what
approach would you take? The intent is to have a single page where the
site admin can add/edit/delete news, articles, bios, user data, etc
thanks for your help,

--
Mark
Jul 10 '06 #2

P: n/a
"Mark Woodward" <ma*********@internode.on.netwrote in message
news:pa****************************@internode.on.n et...
Hi all,

I'm trying to set up a 'control panel' consisting of a table of icons.

The early stages: http://www.deepinit.com/controlcentre.php

Each of these is set up like:

<td>
<input type="image" id="addnews" src="/Image/add24.png"
name="addnews" value="addnews" width="24" height="24"><br />
<label for="addnews">Add News Item</label><br />
</td>

This is all taking place in a html form and I'm using input
type="image"... like 'submit' buttons.

Is this a 'good' approach?

I'm trying to handle the $_POST variable after a user clicks on one of
these but there are differences between firefox and ie6.

Using:
foreach ($_POST as $key=>$val) {
echo $key ."|". $val . "<br />";
}

ie6 is only listing
addnews_x|8
addnews_y|17
Firefox:
addnews_x|10
addnews_y|13
addnews|addnews

Why am I getting x and y co-ordinates?

Why in firefox do I get $val ('addnews|addnews') but not in ie6?
"Creates a graphical submit button. The value of the src attribute specifies
the URI of the image that will decorate the button. For accessibility
reasons, authors should provide alternate text for the image via the alt
attribute.

When a pointing device is used to click on the image, the form is submitted
and the click coordinates passed to the server. The x value is measured in
pixels from the left of the image, and the y value in pixels from the top of
the image. The submitted data includes name.x=x-value and name.y=y-value
where "name" is the value of the name attribute, and x-value and y-value are
the x and y coordinate values, respectively." From:
http://www.w3.org/TR/REC-html40/inte....html#h-17.4.1

Note that php will convert name.x to name_x and name_y since period is
invalid in variable name.

What I'd like to know is what happens in IE if images are disabled or
non-existing image uri is given, and form is submitted by clicking the image
input which is converted to normal submit button, is the actual name then
provided? Are the coordinates (0,0) provided?

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jul 11 '06 #3

P: n/a
Thanks guys,

On Tue, 11 Jul 2006 12:59:10 +0300, Kimmo Laine wrote:
"Creates a graphical submit button. The value of the src attribute specifies
the URI of the image that will decorate the button. For accessibility
reasons, authors should provide alternate text for the image via the alt
attribute.

When a pointing device is used to click on the image, the form is submitted
and the click coordinates passed to the server. The x value is measured in
pixels from the left of the image, and the y value in pixels from the top of
the image. The submitted data includes name.x=x-value and name.y=y-value
where "name" is the value of the name attribute, and x-value and y-value are
the x and y coordinate values, respectively." From:
http://www.w3.org/TR/REC-html40/inte....html#h-17.4.1

Note that php will convert name.x to name_x and name_y since period is
invalid in variable name.

What I'd like to know is what happens in IE if images are disabled or
non-existing image uri is given, and form is submitted by clicking the image
input which is converted to normal submit button, is the actual name then
provided? Are the coordinates (0,0) provided?
Kimmo, I just disabled images in ie6 so I'm only see the placeholders. It
still works as though the image was there (ie getting the x and y coords).
--
Mark
Jul 11 '06 #4

P: n/a
Mel
On 2006-07-10 21:12:13 +1000, Mark Woodward
<ma*********@internode.on.netsaid:
Hi all,

I'm trying to set up a 'control panel' consisting of a table of icons.

The early stages: http://www.deepinit.com/controlcentre.php

Each of these is set up like:

<td>
<input type="image" id="addnews" src="/Image/add24.png"
name="addnews" value="addnews" width="24" height="24"><br />
<label for="addnews">Add News Item</label><br />
</td>

This is all taking place in a html form and I'm using input
type="image"... like 'submit' buttons.
Is this a 'good' approach?

I'm trying to handle the $_POST variable after a user clicks on one of
these but there are differences between firefox and ie6.
Using:
foreach ($_POST as $key=>$val) {
echo $key ."|". $val . "<br />";
}

ie6 is only listing
addnews_x|8
addnews_y|17
Firefox:
addnews_x|10
addnews_y|13
addnews|addnews
Why am I getting x and y co-ordinates?
Why in firefox do I get $val ('addnews|addnews') but not in ie6?

What I'm trying to do is redirect to other pages based on $_POST:

foreach ($_POST as $key=>$val) {
switch (strtolower($key)) {
case 'addnews_x':
PostHandler('addnews', 'news', '/posteditor.php');
break;
case 'editnews_x':
PostHandler('editnews', 'news', '/postsearch.php');
break;
case 'deletenews_x':
PostHandler('deletenews', 'news', '/postsearch.php');
break;
...

function PostHandler($command, $post_type, $redir_page) {
$_SESSION['ctlcentcmd'] = $command;
$_SESSION['posttype'] = $post_type;

ob_end_clean();
header('Location: http://' . $_SERVER['HTTP_HOST']
. $redir_page);
}
This is working but I'm not happy basing this on the x co-ordinate
(eg addnews_x). Surely there must be a better way?

If you wanted to implement a similar icon based 'Control Centre' what
approach would you take? The intent is to have a single page where the
site admin can add/edit/delete news, articles, bios, user data, etc
thanks for your help,
I'd be inclined to make them buttons and use CSS to style them out to
be images (turn off the borders, specify a width and height, set a
background-image). From there you can either use them to sumit to a
page using AJAX, JavaScript, or a plain old form.

Jul 11 '06 #5

P: n/a
Hi Mel,

On Wed, 12 Jul 2006 00:05:19 +1000, Mel wrote:
I'd be inclined to make them buttons and use CSS to style them out to
be images (turn off the borders, specify a width and height, set a
background-image). From there you can either use them to sumit to a
page using AJAX, JavaScript, or a plain old form.
I'd be inclined to agree with you ;-)
Just tried this and it seems much cleaner!!

thanks,

--
Mark
Jul 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.