View Full Version : Need PHP Include Help
BlueEew
Jan 26th 2008, 3:40 pm
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.
Gawk
Jan 26th 2008, 3:49 pm
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"); ?>
This assumes your website pages are .php and the menu.php is in the same directory as the page(s)
Colbyt
Jan 26th 2008, 3:55 pm
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.
BlueEew
Jan 26th 2008, 3:57 pm
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"?
Gawk
Jan 26th 2008, 4:02 pm
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.
Colbyt
Jan 26th 2008, 4:07 pm
You need to change all your .html pages to .php - t
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.
BlueEew
Jan 26th 2008, 4:10 pm
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.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.