Jump to content

[SOLVED] Form submit using Image and not Submit


joePHP

Recommended Posts

Hi,

 

I have a form that it’s action is sent to the same page (the page with the form itself is on action="current_page.php"). Now I know I could use if(isset($_POST['submit'])) so the page refreshes and etc. but what could I do if I used an Image instead of a Submit on the form? Any suggestions?

 

Thanks

 

first, if the form is posting to ifself, leave the action off of the form element. itself is the default action.

 

and, i use this to catch all my posts:

 

<?php
  if($_SERVER['REQUEST_METHOD'] == 'POST'){
    //Form submitted
  }
?>

I still don't see the need. Here is a working example:

 

<?php
  if($_SERVER['REQUEST_METHOD'] == 'POST'){
    //Form submitted
    //do stuff
    print "You submitted: ".$_POST['my_text'];
    exit;
  }
?>
<html>
  <body>
    <form method="POST">
      <input type="text" name="my_text" />
      <button type="submit" style="background:transparent;border:0;"><img src="http://media.msnbc.msn.com/i/msnbc/Components/Art/SITEWIDE/buttons/Submit.gif" /></button>
    </form>
  </body>
</html>

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.