

Hint: You can change the extension of the pages as you wish. By using this method, we also benefit from using standard html designs for the pages. Note that we have included the '.html' extension here so we do not need to enter it when we request the page. Now we check to see if it exists in the default folder in our case it is the pages folder. Of course, to eliminate errors, make sure a page is entered and it is not a blank argument.Ī page is requested and the page argument is not blank.
#Php webdesign code
This php code will check to see if a page is requested. The design is base on creating a default page and a default folder to store pages. Of course you can tell that the 'index.php' file is doing all the work. Now give it a test drive spin! Try and test your design by using the browser to go to: main_folder_of_files/index.php?page=main.html Or simply copy the following pre-made design: Now do the same thing for the other designs, that is: put !!FOOTER!! and design 'footer.html', !!RIGHT_COLUMN!! and design 'right_column.html', put !!LEFT_COLUMN!! and design 'left_column.html' respectively. This design will be the header of all your pages at the end. Now in the 'header.html', design the main header of your website. Go to your 'main.html' and design it as you would like your website layout to look at the end, only here, instead of adding the complete header design, add !!HEADER!! and then go to the 'header.html' file that you created in the "design" folder. $page_content = str_replace("!!COMMON_TAGS!!", file_get_contents("design/common_tags.html"),$page_content)

$page_content = str_replace("!!FOOTER!!", file_get_contents("design/footer.html"),$page_content) $page_content = str_replace("!!RIGHT_COLUMN!!", file_get_contents("design/right_column.html"),$page_content) $page_content = str_replace("!!LEFT_COLUMN!!", file_get_contents("design/left_column.html"),$page_content) $page_content = str_replace("!!HEADER!!", file_get_contents("design/header.html"),$page_content) $page_content = file_get_contents("pages/main.html") $page_content = file_get_contents($_REQUEST.".html") Įcho "Page:".$_REQUEST." does not exist! Please check the url and try again!" $page_content = file_get_contents("pages/".$_REQUEST.".html") Now in the root directory create a file and give it the 'index.php'Īdd the following code to your 'index.php' file (don't worry, it will be explained later!): In the "pages" directory, create a page and give it the name: 'main.html' 'header.html', 'footer.html', 'right_column.html', 'left_column.html'Ĭreate another folder and name it "pages"

Server/Hosting capable of running php scripts.Ĭreate a folder on your server and name it "design".Ĭreate the following files in the design folder: You can use this tutorial to be the basis to make your website easier to maintain and upgrade. In this tutorial I will show you how PHP comes to the rescue with only few lines of code.
#Php webdesign upgrade
The upgrade process becomes even more irritating when you make a change that needs to be upgraded on every page of your website a good example of such a change is adding a button to the header or changing the copy right information in the footer of your website. Whether you have a small or a huge website, you know how much hassle and time it takes to upgrade your web site pages. Note: Although experienced coders might find some useful information in this tutorial, this tutorial is designed to be easily understood and comprehended by total beginners. Creating a Website Design Templating System Using PHP
