input type="image" $_POST queries

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

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

    The early stages:

Each of these is set up like:

<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 />

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.  

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

ie6 is only listing


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');
            case 'editnews_x':
                PostHandler('editnews', 'news', '/postsearch.php');
            case 'deletenews_x':
                PostHandler('deletenews', 'news', '/postsearch.php');

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

        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,


Re: input type="image" $_POST queries

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'];


Mark Woodward wrote:

Quoted text here. Click to load it

Re: input type="image" $_POST queries

Quoted text here. Click to load it

"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  

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:

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 | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)  

Re: input type="image" $_POST queries

Thanks guys,

On Tue, 11 Jul 2006 12:59:10 +0300, Kimmo Laine wrote:

Quoted text here. Click to load it

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).


Re: input type="image" $_POST queries

On 2006-07-10 21:12:13 +1000, Mark Woodward  

Quoted text here. Click to load it

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.

Re: input type="image" $_POST queries

Hi Mel,

On Wed, 12 Jul 2006 00:05:19 +1000, Mel wrote:

Quoted text here. Click to load it

I'd be inclined to agree with you ;-)
Just tried this and it seems much cleaner!!



Site Timeline