Jump to content

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.