Hey, I have a website that as been waiting a long time to be added to the Internet. However I have been delayed, and delayed. Now I have the layout ready and coded I have come across one more problem. I need to add PHP Includes so I can edit the whole website like the menu ect from one file. I used to use SSI, and when I tried to use it. It did not work. I am need in help as soon as possible. If anyone is willing to help. Thanks, BlueEew.
Put your menu html code in a file and give it a name like menu.php In the pages where you want the menu to appear use this code replacing the old menu html: <?PHP include("menu.php"); ?> PHP: This assumes your website pages are .php and the menu.php is in the same directory as the page(s)
And if it is not in the same directory just add directory/ in front of the file name. If it happens to be up (back) one level add ../ in front of the filename. You can also use abosolute server path but that can get messy.
The webpages are in the .html format, so how would I do it like that? Change the "menu.php" in the PHP script to "menu.html"?
You need to change all your .html pages to .php - this also means changing the internal links to point to the .php pages instead of the .html Make a backup of your site, put it in a test directory and rename the webpages to .php - this will allow you to test it all and when you are happy copy them to the main site.
You can also declare that html pages are to be parsed as php in the .htaccess file. The exact syntax escapes me at the moment. One thing you do not want to do is have <head> or <body> tags on the pages that are to be included. Most browsers will render it correctly but it not the right way to it.
Thanks a lot guys and gals, that was quite easy with your help. Its a good job that I have not yet started adding the pages yet. Thanks again.