Originally posted by malbera
When you submit a form with radio buttons, the php script doesn't get the value of the radio button, only if it is checked or not.
if it isn't, the script doesn't get anything at all about that radio button
that's why you get that error when no radio button is checked...
This is absolutely not the case. Since grouped radio buttons all have the same name, only their values differ, therefore the value must be available to PHP. Otherwise, we don't know which button was selected...
The code I posted earlier works fine using the $HTTP_POST_VARS array on PHP 4.0.6. If the $_POST array behaves differently when using radio buttons in newer versions of PHP than the deprecated $HTTP_POST_VARS array (and I see no logical reason why it should), the PHP developers have not made this point abundantly clear.
I do not dispute the fact that using isset(), as your code example shows, will work fine. However, simply knowing that a button is set does not tell the application which button was selected...
As far as knowing whether or not the form was submitted, by applying a name/value pair to the submit button (as my earlier post also suggests), simply test to see if the $_POST['button'] is the same as the value="" attribute of the button. If it's the same, the form was submitted. If not, the form was not submitted.