To test a form I usually send the form contents to a php file that contains the following; foreach($_POST as $nm => $val) echo "_POST[".$nm."] [".$val."]<br>"; foreach($_GET as $nm => $val) echo "_GET[".$nm."] [".$val."]<br>"; Checkboxes and radio buttons only send their value if the control is "checked". You can have multiple submit buttons (type="submit") on a form, but you should assign them different name parameters to recognize which one is clicked (any one of them will cause the form to be submitted, but the only one that will establish a $_POST entry named "submit" is the submit control that is named "submit" (name="submit"). Pressing enter is not sensed by most controls. Most browsers will look at the field the cursor is positioned on when enter is pressed, and if it is not one of the controls that response to an enter, it scans the DOM (list of controls), and will apply the enter to the first control that responds to an enter, most common is the type="submit" control. If a select control is between the text box and the submit button (in the DOM list) the current entry for the select list will be selected and the form will not be submitted unless the list includes a onChange="this.form.submit(); " javascript entry. Be careful designing forms that are dependent on some of these behaviors, like positioning a submit button to the right of a text box to intentionally receive the "enter", because different browsers will probably behave differently. Hope this helps a bit. Warren Vail Vail Systems Technology -----Original Message----- From: Keith [mailto:survivor_bus@xxxxxxxxxxx] Sent: Friday, August 28, 2009 9:51 PM To: php-general@xxxxxxxxxxxxx Subject: Re: Re: Best way to test for form submission? I've encountered issue with checking $_POST['submit'] if(isset($_POST['submit'])) {} If the form consists of checkbox/radio and text field, some of my forms can be submitted by just press [ENTER] at the end of one of the text field. In this case, the $_POST['submit'] is set even the submit button was not clicked. However, in some of my forms, $_POST['submit'] will not be set if I submit the form by pressing [ENTER] in one of the text field. So, if the later case happen, I need to remind the user to explicitly click the [Submit] button. I don't know why or in what condition that pressing [ENTER] will not submit the whole form include the $_POST['submit']. Keith "Ashley Sheridan" <ash@xxxxxxxxxxxxxxxxxxxx> wrote in message news:1251467419.27899.106.camel@xxxxxxxxxxxx > On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote: >> On 08/27/2009 11:09 PM, Adam Jimerson wrote: >> > This question might give away the fact that I am a php noob, but I am >> > looking for the best way to test for form submission in PHP. I know in >> > Perl this can be done with >> > >> > if (param) >> > >> > but I don't know if that will work with PHP. I have read the Learning >> > PHP 5 book and the only thing that was mentioned in the book was the >> > use >> > of something like this >> > >> > print "<p>Hello ".$_POST['username']."</p>"; >> >> Sorry copied and pasted the wrong line (long day) >> >> if (array_key_exists('username',$_POST)) >> > >> > I'm sure that this is not the best/recommended way to do this but I'm >> > hoping someone here will point me in the right direction. >> >> > > The best way I've found is to do something like this: > > if(isset($_POST['submit'])) > {} > > Note that in-place of submit you can put the name of any form element. I > chose submit here, because every form should have a submit button. Note > also that this will only work if you have given your submit button a > name: > > <input type="submit" name="submit" value="Submit"/> > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php