View Single Post
Old 05-06-2012, 06:50 PM   PM User | #5
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
tango while I agree with you, this only occurs if you have only one text input in your form and then a submit button. If you more than one text input hence your example it will send the post from the submit button.

Most forms will have way more than one input of type text but for those that don't yes you need to check for the post of a different field.

If you have more than one text/hidden field you can now for isset($_POST['submit']) or whatever your submit button may be named and it will work regardless of clicking on it with your mouse.

It does not work like I have mentioned if you use the hidden input as your second input. An example of what I mean

The following will pass in the post for the submit button.
PHP Code:
<html>
   <head>
      <title>The if(isset($_POST['submit'])) bug demo.</title>
   </head>
   
   <body>
   
<?php
if (isset($_POST['submit']))
   {
   print 
'Your data was processed!<br><br>This is your $_POST submission:<br>';
   
print_r($_POST);
   }
else
   {
   print 
'No data processed.<br><br>This is your $_POST submission:<br>';
   
print_r($_POST);
   }
?>
      <br><br>
      <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post">
         Put the cursor in a box and press the enter key:<br>
         <input type="text" name="sample" value="Some sample text.">
         <input type="text" name="sample2" value="Some more text." />
         <input type="submit" name="submit" value="Then the next time, click this">
      </form>
   </body>
</html>
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||

Last edited by _Aerospace_Eng_; 05-06-2012 at 07:06 PM..
_Aerospace_Eng_ is offline   Reply With Quote