Jump to content

Using an image as submit button?


Fenhopi

Recommended Posts

Hey I'm trying to use an image as a submit button for my form.

I use this code:

<INPUT NAME="post" TYPE="image" SRC="images/scribblebutton.jpg" HEIGHT="30" WIDTH="80"  ALT="OO it up!">

To trigger the php script. However when I use the image as a button it doesn't post the values like it does when I use a normal submit button..

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/205125-using-an-image-as-submit-button/
Share on other sites

No javascript needed.

 

Check x and y values of the image like so:

 

<?php
//based on your image button;
if (isset($_POST['post_x']) || isset($_POST['post_y'])) {
    //now you're set .. continue;
}
else {
    //image/submit button not pressed;
}

http://us.php.net/manual/en/faq.html.php#faq.html.form-image

 

Using an image as a submit button causes the _x and _y coordinates where the image was clicked to be sent to the server. You can either detect that or you can use a hidden field in the form and detect if the form was submitted by detecting if the hidden field name is set.

Hey I'm trying to use an image as a submit button for my form.

I use this code:

<INPUT NAME="post" TYPE="image" SRC="images/scribblebutton.jpg" HEIGHT="30" WIDTH="80"  ALT="OO it up!">

To trigger the php script. However when I use the image as a button it doesn't post the values like it does when I use a normal submit button..

 

Any ideas?

 

Hi! Yes just use <input type='image' />

The image type is automatically a submit mode button.

Edit sorry, i misread and answered a bit quickly. But it works for me when im submitting via type='image'

Hey I'm trying to use an image as a submit button for my form.

I use this code:

<INPUT NAME="post" TYPE="image" SRC="images/scribblebutton.jpg" HEIGHT="30" WIDTH="80"  ALT="OO it up!">

To trigger the php script. However when I use the image as a button it doesn't post the values like it does when I use a normal submit button..

 

Any ideas?

 

Hi! Yes just use <input type='image' />

The image type is automatically a submit mode button.

Edit sorry, i misread and answered a bit quickly. But it works for me when im submitting via type='image'

Can depend on what browser you are using.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.