Jump to content
xisto Community
Albus Dumbledore

How To: Make A Simple Php Site Making one file show up on all pages using php

Recommended Posts

I have looked all over the site and could not find anything that was like this simple, or just like this at all..

For some people i know that you are using a basic HTML site...and having a big menu if you want to add somthing you have to go into every one of the pages and add or remove or edit what you want to do, but with somthing verry simple all you would have to do is edit one file, and all of the pages that have the PHP script on them would suddenly change to what that one file is.

So to start off if you are planning on using this little tirck, the page that you are putting the code on must be a .php page, so instead of 'index.html' it would be 'index.php' this changes none of the aspects of the page except for the fact that you can put php scripts in the page now, if you are unsure how to do this simply open the file in the editing program you use and when it asks what you want the name to be put 'THENAME.php" and it will be saved as a .php file..

now to the script...wherever you want the content of that one file to show, you will need to put this code

<?php include("FILE NAME.html"); ?>

you simply need to replace the FILE NAME with the name of the file in which you want to show. and if it is in a different directory put DIRECTORY/FIILE NAME instead...simple eh..

but now, for the file that you want to put on the pages...all you need to do is make a normal html file or any other file that you have that you want to include with the content, so if you want it to be a menu for example...

<div><b>.:Site Navigation:.</b><br>- <a href="link here">Forums</a><br>- <a href="link here">Contact Us</a><br>- <a href="link here">Employee's</a><br>- <a href="link here">Affiliates</a><br>- <a href="link here">Affiliation</a><br><b>.:Tutorials:.</b><br>- <a href="link here">CSS</a><br>- <a href="link here">HTML</a></div>

that could be saved as menu.html and you would just have to change FILE NAME to 'menu' and it should show up! just be sure that the file extention is .html *edit* edited it per Tyssen's post, now it DOES NOT have to be a .html file, i have tested it out and it works so that way you dont need to use .html, you can also use any other ones such as .php....who woulda guessed lol..thanx tyssen

well that is about it! my thanx to Phillip, aka webmaster_2006 for clearning up the matter of the page HAVING to be .php, for me!

*edit* edited it per Tyssen's post of clearing it up, thanx! it did mix it up a little>_<
Edited by Albus Dumbledore (see edit history)

Share this post


Link to post
Share on other sites

that could be saved as menu.html and you would just have to change FILE EXTENTION to 'menu' and it should show up!

I think you want to clear that statement up cos at the moment it sounds like you're saying you should change the file extension to .menu.

Share this post


Link to post
Share on other sites

thanx, Tyssen, i retyped a few things and hopefully it is clear now,@ apollo, im sure that people who are making sites and dont use somthing like this and are just now finding out about somthing like this think differently, if you had 30 pages on your site all with a menu and you wanted to add one bloody page...would you want to go through and change all 30?it may be a small thing compared to what else they may be able to do but i am sure some of the noobs find it allot more usefull than going through all of their files and changing it like i said above.

Share this post


Link to post
Share on other sites

that can be done in html only..i dont see how that is php except that ure changing the index.php file thing..

You can't do PHP includes with HTML.
By the way Albus, your file doesn't have to have an .html extension, it can be whatever you want - .php, .asp, .txt, .inc. The page that calls the include, rather than the include separately is what gets parsed, so it doesn't matter what format the include is in.

Share this post


Link to post
Share on other sites

that can be done in html only..i dont see how that is php except that ure changing the index.php file thing..


well my friend calls it php, and call it php so i just called it php, we called it php because of the
<?[b]php[/b] include("FILE NAME.html"); ?>

php in the code needed to make it work.

@Tyssen, ok thanx, i believe you but i think i am going to also test that out before i edit the post because the person who taught me said it has to be a .html, if it works that way i will change it and if it does i will tell the person who told me, lmao..also if it is true thanx for advancing my knowledge in php :-D

Share this post


Link to post
Share on other sites

hey thx for that handy tipi m used to editing every html file which i wanted to add a link or so but now there is no need to do that, thx to your tutorial!may be i should start learning php now..........:huh:

Share this post


Link to post
Share on other sites

i tryed to make my own php site, but it was too dificult, so i made it in html and take php forum, from phpbb.com. it is very nice forum, but i saw it almost everiwhere.

Share this post


Link to post
Share on other sites

You can't do PHP includes with HTML.

By the way Albus, your file doesn't have to have an .html extension, it can be whatever you want - .php, .asp, .txt, .inc. The page that calls the include, rather than the include separately is what gets parsed, so it doesn't matter what format the include is in.

 


thanx for telling me of this! i have checked it out just to make sure (not that i didn't believe you) and it works just the same and just as fine...so i have edited the post to say that the

 

<?php include("FILE NAME.html"); ?>

 

stuff in bold up there DOES NOT have to be a .html, but can be anything you want it to be i suppose, i only tryed it with php but it worked as well! thanx for telling me

Share this post


Link to post
Share on other sites

Hi Guys I'm New to these forums and couldn't help but spot this briefing on php.Just a few questions on this, Can you use the afforementioned example on a freely hosted site? ie; yahoogeocities, Lycos, Tripod or any other? if you can use your example on a freely hosted site, but not on any of the ones i've listed. Then can you advise me on which freely hosted sites will allow php?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.