.:Urban-Glam.Com:. .:Urban-Glam.Com:.
.:Home:. .:Gina:. .:Domain:. .:Exits:. .:Tutorials:. .:Myspace:. .:Portfolio:.
PHP Includes

Coding your site in PHP includes is very easy and it will save you a lot of time in the future. Instead of coding your site in .html or .htm I encourage you to try this because I use it and it is so easy and helpful.

For an example, let's just say you already have your site coded in PHP, but you want to totally revamp your site, you would only have to change 2 files instead of your WHOLE site. That is the easy part.

Before we start please make sure that your site has PHP support.

Rename all your files to .php, so if you have a page called visitor.html, rename it to visitor.php. You DO NOT have to rename image files or certain files like .cgi files.

Let's break apart a page coded in PHP Includes. I like to think of it as a sandwich. Because it contains 3 things. And those 3 things are the header.php, your actual content for a page, & a footer.php.

Let's start with the header.php. This file basically holds the title of your page, style.css, layout code, and things of that nature. Below is an example of a typical header.php.

>html>
>head>
>title>TITLE OF YOUR SITE</title>
>link rel="stylesheet" type="text/css" href="style.css" />
>head>

>body>
>img src="URL OF LAYOUT" style="position:absolute; left: 0px; top: 0px;">

>div style="position:absolute; top:#; left:#; width:#;">

Now the footer.php. This file basically holds the closing of your tags and content like your menu if you have one. Below is an example of a typical footer.php.

</div>

</body>
</html>

So make your header.php & footer.php and upload them to your main directory. Now add this code to the very top of ALL your pages...

<?php include ("header.php"); ?>

Add this code to to very bottom of ALL your pages...

<?php include ("footer.php"); ?>

So every page should look like this, I am using a bio page as an example...

<?php include ("header.php"); ?>

Hello, my name is Gina. I am from...

<?php include ("footer.php"); ?>

And that is basically it. If you ever wanna change the way your site looks and is set up just edit the header.php & footer.php.

One more thing, some people are a little confused as to what to put on their index.php, especially if they use a blogging tool like Greymatter. This is how your index.php page should look if you use a blogging system...

<?php include ("header.php"); ?>

<?php include ("http://yoursite.com/blogging tool folder here/"); ?>

<?php include ("footer.php"); ?>

< Back