On the advice of a more experienced developer, I have always coded my web pages that require user input (form processing, database administration, etc.) as self-referential pages. For PHP pages, I set the action of the form to the 'PHP_SELF'
element of the $_SERVER
predefined variable, and depending on the arguments that I pass the page logic determines which code block(s) to execute.
I like that all of the code is contained in one file, and not spread around to various result pages. The one issue I've found is that my stats parsing programs can't differentiate between the first view of the page, and subsequent views (e.g. when the form has been submitted). A long time ago, when I used CGI or CF to create the pages, I directed the user to a different result page, which showed very neatly how many times the form was actually used.
What is the best practice for these types of pages in web development? Are there other, more compelling reasons for using (or not using) self-referential pages?