Skimming, I'd suggest putting some of the common things to all pages in a config.php file and require_once('config.php') at the top of each file.
This would be the database connection information, header and footer functions, css, etc.
I only read the code, I didn't run it, so that's all the input I have at the moment.