Submitting a form to PHP checker creates error.

Discussion in 'PHP' started by Skinny, Dec 28, 2006.

  1. #1
    Alrite I got a script that on send needs executes:

    <form method="POST" action="<?php echo $PHP_SELF; ?>">
    Code (markup):
    Now the original submission code was:

    <input type="submit" name="do" value="Send">
    Code (markup):
    Now I want to use an image as my submit button so I used:

    <input type="image" src="http://i74.photobucket.com/albums/i245/msmug/send.jpg" border="0" name="do">
    Code (markup):
    The problem is the when I hit submit using an image the code doesn't go through my php code to check for errors. However, using the button there is no problem, the button will scan for errors correctly.

    What am I doing wrong?

    Skinny
     
    Skinny, Dec 28, 2006 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Give the image an ID too.

    Peace,
     
    Barti1987, Dec 28, 2006 IP
  3. Skinny

    Skinny Peon

    Messages:
    1,864
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I've tried using the name="do" field. Isn't that the ID.

    It basically checks 'do' on the submit button. But it seems when using an image this variable isn't passed.

    Skinny
     
    Skinny, Dec 29, 2006 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Try giving it a value.

    
    <input type="image" src="[...]" border="0" name="do" value="Send">
    
    HTML:

    Or add a hidden field with the key and value...
     
    nico_swd, Dec 29, 2006 IP
  5. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #5
    name="do" and id="do"

    If that fails what condition are you using in your php script?
     
    mad4, Dec 29, 2006 IP
  6. Rogem

    Rogem Peon

    Messages:
    171
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try making the type submit and making the scr/value the picture. Or put the following code

    [button]HTML For Image[/button]

    Little people know of the button tag.

    Maybe added a CSS to your submit button so that it comes up as a image, but make the type submit. I'm sure it's important for the value of the submit to be submit.
     
    Rogem, Dec 29, 2006 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    Reason : the raw output from the above form will be :

    
    Array
    (
        [do_x] => 44
        [do_y] => 47
    )
    
    PHP:
    so do this instead :

    
    <style type="text/css">
    .submit
    {
    background-image:url(http://i74.photobucket.com/albums/i245/msmug/send.jpg);
    border:0px;
    width:97px;
    height:104px;
    }
    </style>
    <form action="" method="post">
    <input type="hidden" name="do" value="Send">
    <input type="button" class="submit" border="0" onclick="submit()">
    </form>
    
    PHP:
    or similar
     
    krakjoe, Dec 29, 2006 IP
    Skinny likes this.
  8. Skinny

    Skinny Peon

    Messages:
    1,864
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #8
    @ everyone. Thanks so much. I added a hidden value (do) and then just created the image button like before an it works like a charm.

    Thanks again

    Skinny
     
    Skinny, Dec 29, 2006 IP