Help with Using a custom image for a form submission button

  • natas
  • PHP Ninja
  • Proficient
  • natas
  • Posts: 308
  • Loc: AFK

Post 3+ Months Ago

In the past, I've always used the standard "submit" buttons..
Code: [ Select ]
<input type="submit" name="submit" value="submit" >


Then, when I want to check to see if the button was clicked, I do it this way..

Code: [ Select ]
if (isset($_POST['submit']))


The code to use a custom image for a submit button is a little different, and my PHP code to check to see if that button was clicked isn't working. What am I doing wrong? Here's the stripped down code I'm using.

Code: [ Select ]
if (isset($_POST['submit']))
{
echo "button was clicked";
}
<form>
First name: <input type="text" name="firstname" /><br />
Last name: <input type="text" name="lastname" />
<input type="image" src="images/login-btn.png" name="submit">
</form>
  1. if (isset($_POST['submit']))
  2. {
  3. echo "button was clicked";
  4. }
  5. <form>
  6. First name: <input type="text" name="firstname" /><br />
  7. Last name: <input type="text" name="lastname" />
  8. <input type="image" src="images/login-btn.png" name="submit">
  9. </form>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • natas
  • PHP Ninja
  • Proficient
  • natas
  • Posts: 308
  • Loc: AFK

Post 3+ Months Ago

print_r ... what a useful tool.

I guess when you use an image for a submit button, it submits name_x and name_y on submit instead of just the "name".

I changed my code to
Code: [ Select ]
if (isset($_POST['submit_x']))

and it works just fine.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 156 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.