Ok I'm almost done with my uncles website. Now, I want to beable to edit one file and it will edit the part of code on all webpages that i changed. I know its <includes bluh> HTML: but i dont remember, i know when i had my wrestling site up i had it working someone set it up for me like that but i foget the code, could someone pleae point me in the right direction. thanks...i will rep if ya help.
He did it in html though. I think it was includes...is there one for html? What is it for html? I hate going though 10000 pages edting so he set it up where if i want to add a link to the nav, i go to the nav page and edit contetn page edit the content file etc.
<!--#include virtual="your file here" --> Code (markup): it may only work if the file extension is shtml or shtm
That looks familiour..i tried it and when I open up my file on my local all i get is a white page...so maybe there is somthing i can do with that. I know it dont only work with .shtml and stuff cause ived used .php and .txt
So how do i call the php part then? and what if im wanting to include more then one file? alos would i just put the html of the paragraphs under the php?
You have a myPHPpage.php you do your includes myInclude1.inc.php, myInclude2.inc.php, etc... You insert your includes <?php include("myInclude1.inc.php"); ?> <P> <?php include("myInclude2.inc.php"); ?> Etc... SO you can edit only the include without to touch the myPHPpage.php
Above seems correct, this is the way i would go about it, header.php <html> <head> <title>...</title> </head> <body> <div id="header"> <img src=".." alt=""> </div> <div id="wrapper"> Code (markup): then in another file maybe, navigation.php <ul id="nav"> <li><a href="#">Link</a></li> <li><a href="#">Link 2</a></li> </ul> Code (markup): then i would have a footer.php file, <div id="footer"> Footer Info </div> </div> </body> </html> Code (markup): I would place all of the above files in a folder called includes, then i would create a file called index.php in the root folder; index.php <?php include("/includes/header.php"); include("/includes/navigation.php"); ?> <div id="content"> <p> Your home page content here </p> </div> <?php include("/includes/footer.php"); ?> Code (markup): That when run on a server with PHP installed would produce the following output for the index.php <html> <head> <title>...</title> </head> <body> <div id="header"> <img src=".." alt=""> </div> <div id="wrapper"> <ul id="nav"> <li><a href="#">Link</a></li> <li><a href="#">Link 2</a></li> </ul> <div id="content"> <p> Your home page content here </p> </div> <div id="footer"> Footer Info </div> </div> </body> </html> Code (markup): Then i would use the same sort of structure as the index.php page for all pages. This way when you want to alter say the navigation.php page, you only have to edit one file! N.B. The above is not tested and there are probably mistakes in the code. Some people also (the proper way seem to use the extension .inc.php which you should also probably use instead of .php)
erm...can someone talk me thogh this on msn as i havent done it think way before? Is it better like this thin the way i was doing it b4
I suggest you read my PHP & Server-Side Includes tutorial from a couple years back then: http://forums.digitalpoint.com/showthread.php?p=2145250#post2145250
The extension may be anything or nothing at all. I tend to use .inc, as in globalnav.inc, footer.inc, etc.. The include function is at its essence is a simple paste operation. cheers, gary
And if those includes contain any sensitive information (such as your MySQL username and password data) then saving those includes as plain .inc files will mean they're getting served as plain text to anyone who wants to see them - a BAD IDEA if you ask me.
Dan, you're right, as far as you go. I did not address the security issue, and maybe I should have. My only intent was to clarify that the extension used doesn't matter. As to security, I put my included files in a directory not in the document root's tree. They are not available to the web server. This is security 101 for any PHP/MySQL (or whatever combo you might use) scripting. You could, of course, make .inc files unavailable by adding a file directive to the server config file or to your .htaccess file if you don't have root access. <Files ~ "\.inc$"> Order allow,deny Deny from all </Files> Code (markup): In the usual case, a simple html snippet is not a security issue no matter where it is. cheers, gary