DnaJ:
That's stupid, what if you want to have multiple form handlers on one page?
Terrible way to do that.
It all depends on whether you have one or multiple forms on one page that shares one script for the processing.
For multiple handlers on same form, that's when you do add a check for the individual $_POST['submitbutton'] values.
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
...if (isset ($_POST['submit1'])) { # do task 1 }
...elseif (isset ($_POST['submit2'])) { # do task 2 }
...elseif (isset ($_POST['submit3'])) { # do task 3 }
}
else
{
...# normal processing
}
Or, from your reply, do you prefer this instead?
if (isset ($_POST['submit1'])) { # do task 1 }
elseif (isset ($_POST['submit2'])) { # do task 2 }
elseif (isset ($_POST['submit3'])) { # do task 3 }
else
{
... # normal processing
}
They don't have much difference except for the extra if() statement for checking the request_method.
It's all a matter of preference, since both works just fine.
However, if you really have to have multiple forms on the page, do you really want to put the different processings in the same script? Personally, i don't like cramping 2-3 different $_POST processings in one script. But it's all up to the developer (and it's a different discussion from the current topic)