Posts Tagged ‘sample coding for php web page’


How to design a website that is easily modified or updated.

Friday, April 18th, 2008

If you have a website with ten pages, updating should not be a problem. But how about if you have more pages..?

Lets say you can have your menu in one page for example and display it in every page of your website. When you want to change something in the menu, you have to edit only one page, and it automatically changes in other pages.

1)

<html>
<head>
<title> Simplified php web development</title>
</head>
<body>
Top menu here<br>

Save above code as header.php

2)

Main part of the web page<br>

Save it as main.php

3)

copyright

</body>

</html>

Save it as footer.php

What we have done here is, we created three different .php files namely: header.php, main.php and footer.php. Later we will be linking them together within a page to create one whole page. Basicaly header.php should include all the meta tags and top menu. And main.php should include all the body content. As for the footer.php it will include Copyright notes and other content like bottom menu.

4)

<?include (”header.php”); ?>
<? include (”main.php”); ?>
<? include (”footer.php”); ?>

Save it as index.php. All pages should be in the same folder. Otherwise the linking won’t work. Now access the index.php through your webserver. You should be able to see the following page.