I see a lot of forms that are built like this:
<FORM ACTION=<? echo $PHP_SELF; ?> >
I've also seen this:
<FORM ACTION=formhandler.php>
where formhandler.php does its work (saves or updates data in the database, most likely), then redirects to the next page in the flow (which could be back, or up, or anywhere, really).
What are the advantages and disadvantages of each of these styles (I'll call them 'self' and 'handler')? I'm interested in maintainability first, then performance, then everything else.
It seems that the 'self' style could get better performance since the php script is pretty much guaranteed to be in memory and with an optimizer it'll be faster the second time through. But it's cluttered with code for multiple purposes (drawing the page, handling form submission), and it'll be bigger and thus load slower the first time through.
There's a hybrid style, where PHP files are 'included as needed for the intended function of the page, e.g.
if ($action='submit') {
include_once("handler.inc");
} else {
include_once("draw_page.inc");
}
This might defeat the optimizers, though.
Any hints and tips will be appreciated. I'm getting ready to build a site with PHP and (probably) MySQL, and I'd like to get thie right (whatever 'right' means) the first time.
TIA
--Kurt