Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    submit form using image didnt work.. Help pls

    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

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    you need to add a javascript form submit function. not php related.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    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...unkyforms2.htm
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by GJay View Post
    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.

  • #6
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Oh okay, so that means theres no solution with my problem.. but thats what i want to .. anyways i will try another alternative..

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by rafiki View Post
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    okies thanks for that..

  • #9
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Yes there is a solution - as i posted.
    You can not say you know how to do something, until you can teach it to someone else.

  • #10
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    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

  • #11
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #12
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    can u give me an example has relation with javascript.. like what you said at the top.. tnx

  • #13
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    actually thats why Im trying to use image as submit button, inorder to include the file..

  • #14
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I think have an script somewhere that uses an image as a submit button that catches the images coordinates. Let me look for it.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #15
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    you need to add 2 characters to your current code:
    PHP Code:
    if(isset($_POST['samok.x']))

    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •