Thanks to you tommynanda I have rewritten most of my coding and have became a noticably cleaner coder. I no longer have all that phhtmpl (PHP+HTML mix) going on all over my code.
Here's the final result of what I've done.
Root Folder
index.php
Sources Folder
lib folder
mysql_connect.php
index.php - > main index page
blah.php -> insert page name for the modulization
Templates Folder
header.php
footer.php
blah.php -> insert name of other templates used in future
Now that said I am not only using index.php for a main modulization directortor, but also as a globals holder.
Index.php - Looks like
<?php
include("W:/www/modulization/templates/header.php");
include("W:/www/modulization/sources/lib/mysql_connect.php");
///////////////////////////////////////////////////////////////
$page = $_GET['page'];
if ($page) {
if (file_exists("W:/www/modulization/sources/$page.php")) {
include("W:/www/modulization/sources/$page.php");
} else {
include("W:/www/modulization/sources/error.php");
}
} else {
include("W:/www/modulization/sources/index.php");
}
///////////////////////////////////////////////////////////////
include("W:/www/modulization/templates/footer.php");
?>
/// Breakdown and explain?
nclude("W:/www/modulization/templates/header.php");
include("W:/www/modulization/sources/lib/mysql_connect.php");
The top html -> php header to call the template header, along with the mysql_connect so I have easy access tonncection in all files.
$page = $_GET['page'];
Get's the page ?page=
if ($page) {
if (file_exists("W:/www/modulization/sources/$page.php")) {
include("W:/www/modulization/sources/$page.php");
} else {
include("W:/www/modulization/sources/error.php");
}
} else {
include("W:/www/modulization/sources/index.php");
}
If the page is not blank then check and see if the file exists (To keep from shooting errors and seeing directory structures). If it exists then show it..
If the page is blank then show just the index.php
include("W:/www/modulization/templates/footer.php");
then the footer junk!