The actaul page file should contain only what is diffrent about that page from a standard "page" on your site(eg the page title, the index page may have code to get the latest news, etc). Everythin which is (or may) be used in more than one place, should be moved to external php files, and included. Examples are:
- Database infomation (password, username, etc)
- Header/Footer
- Login code
This makes the code much easyer to manage. Eg if you change the database password, its only one file that needs updating, or if you decided to add a banner to the header, its again only one page not all the pages that need changing.
It also makes adding new features much less work, eg a new page may simply be:
<?php
require ('config.php')
require ('start.php')
require ('header.php')
//custom page stuff
require ('footer.php')
?>
or adding auto login via cookies, is a simple change to the Login() function (creating a cookie), and start.php (checking for the cookie + calling Login()).
Also you can easyily transfer these files to other projects in the future.