A Dynamic Site in 2 Minutes

They have: 52 posts

Joined: Dec 2002

For those who want a dynamic site, I'll show you how to do it in PHP, ASP, Cold Fusion or Java. The really nice thing about using Include Files is when you change the include files, it changes every page on your site:

For PHP:
Start by changing index.htm to index.php. Then use this code:

<?php

include 'includes/header.php';
?>

add all of your body text, tables, pictures, etc. here (just regular html. cut and paste from your old page if you like)
<?php

include 'includes/footer.php';
?>

Next, create header.php and footer.php and place them in a folder called "includes". In the header file, add your page title and navigational links. In the footer file, add your copyright notice.

To create new pages keep using the above code.
When you want to update links in the header or the copyright date in the footer, all you have to do is change one file, not the whole site.

For ASP:
Same as above but each page with includes should start with:

And in ASP...

<?php
@ Language=VBScript
?>

<?php
Option Explicit
?>

Then use this code for the includes:

add your content here

For JSP
Use this code for the includes:

<?php
@ include file="header.jsp"
?>

content goes here
<?php
@ include file="footer.jsp"
?>

For Cold Fusion
Use this code for the includes:

body here

After you get used to doing this you can include files that run programs on the server and then output information. For example, you might want to output random links from your forum, so you create a program that randomly selects from a list of forum posts and then outputs the html to the include.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Nice idea, but it doesn't take into account unique meta tags, unique page titles, et cetera.

He has: 1,380 posts

Joined: Feb 2002

I use the same sort of format myself, as of late.

I setup the title like<title>Page<?=$title?></title>

And then in the configuration page, $title may be

<?php
$title
= \":&nbsp;&nbsp;Hello\";
?>

You can do that for almost anything...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.