...

View Full Version : submit form using image didnt work.. Help pls



che_anj
07-30-2007, 12:10 PM
Hello anyone can help me bout my problem, I was trying use image to submit form.

heres my code:
<form name="myform" method="post">
<INPUT TYPE="image" SRC="images/add.gif" VALUE="Submit now"
ALT="Add Actions" NAME="samok">
</form>

if(isset($_POST['samok']))
{
include 'actions.php';

}

by using input type as image the include file will not appear.

But by using this code below it will successfully work..

<form name="myform" method="post">
<INPUT TYPE="submit" name="samok" value="Add Actions">
</form>

if(isset($_POST['samok']))
{
include 'actions.php';

}
Could anyone tell me whats wrong? thanks

rafiki
07-30-2007, 01:45 PM
you need to add a javascript form submit function. not php related.

timgolding
07-30-2007, 01:57 PM
alternatively you could just make it a submit button and style the submit button accordingly

heres a website that looks at styling forms

http://www.outfront.net/tutorials_02/adv_tech/funkyforms2.htm

GJay
07-30-2007, 01:58 PM
you need to add a javascript form submit function. not php related.
no you don't, images can submit forms.

The gotcha is that it's not the name of the image that gets passed to the server, but the co-ordinates of the click in the form '<name>.x' and '<name>.y'. If you stick print_r($_POST);exit' at the top of your script before you hit submit, you'll be able to see what gets passed through, and what you should check for.

rafiki
07-30-2007, 02:02 PM
no you don't, images can submit forms.

The gotcha is that it's not the name of the image that gets passed to the server, but the co-ordinates of the click in the form '<name>.x' and '<name>.y'. If you stick print_r($_POST);exit' at the top of your script before you hit submit, you'll be able to see what gets passed through, and what you should check for.
well still to make the HTML use an image for submit button its not really php related.

che_anj
07-30-2007, 02:09 PM
Oh okay, so that means theres no solution with my problem.. but thats what i want to .. anyways i will try another alternative..

_Aerospace_Eng_
07-30-2007, 02:13 PM
well still to make the HTML use an image for submit button its not really php related.

Yes it is. You can use an image as a submit button. I do so on my site
http://prdesignz.com/index.php?page=contact

As said the coordinates are sent with the submit. What I do on my site is I submit the form to another page and this seems to handle the image submit just fine. To prevent spam I am using sessions and then checking the session before the form is submitted to be sure the session ids match.

che_anj
07-30-2007, 02:18 PM
okies thanks for that..

timgolding
07-30-2007, 02:23 PM
Yes there is a solution - as i posted.

rafiki
07-30-2007, 02:24 PM
Yes it is. You can use an image as a submit button. I do so on my site
http://prdesignz.com/index.php?page=contact

As said the coordinates are sent with the submit. What I do on my site is I submit the form to another page and this seems to handle the image submit just fine. To prevent spam I am using sessions and then checking the session before the form is submitted to be sure the session ids match.

how is it php related, to make the image a submit button php == server side, button is on clientside, aka javascript html css :S confised.com :)

_Aerospace_Eng_
07-30-2007, 02:41 PM
Because the button submits just like a normal submit button but to get it to submit to the same page you need to capture the x and y coordinates that submitted along with the name of the image button therefore you need to use php to get these coordinates.

che_anj
07-30-2007, 02:41 PM
can u give me an example has relation with javascript.. like what you said at the top.. tnx

che_anj
07-30-2007, 02:43 PM
actually thats why Im trying to use image as submit button, inorder to include the file..

_Aerospace_Eng_
07-30-2007, 02:46 PM
I think have an script somewhere that uses an image as a submit button that catches the images coordinates. Let me look for it.

GJay
07-30-2007, 05:42 PM
you need to add 2 characters to your current code:


if(isset($_POST['samok.x']))
{

CFMaBiSmAd
07-30-2007, 06:22 PM
Dots are not permitted in variable names.

Perhaps the PHP manual FAQ will help to solve this PHP issue - http://www.php.net/manual/en/faq.html.php#faq.html.form-image

firepages
07-30-2007, 06:58 PM
how is it php related, to make the image a submit button php == server side, button is on clientside, aka javascript html css :S confised.com :)
because as shown in the link above PHP converts the img.x and img.y to img_x and img_y , so you simply check for $_POST['img_x'] or $_POST['img_y'] or simply ignore the submit button and send a hidden field and check for that instead.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum