Html from HTML help

Discussion in 'HTML & Website Design' started by wwe9112, Feb 27, 2008.

  1. #1
    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.
     
    wwe9112, Feb 27, 2008 IP
  2. Codythebest

    Codythebest Notable Member

    Messages:
    5,764
    Likes Received:
    253
    Best Answers:
    0
    Trophy Points:
    275
    #2
    include tags are PHP...
     
    Codythebest, Feb 27, 2008 IP
  3. wwe9112

    wwe9112 Guest

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    wwe9112, Feb 27, 2008 IP
  4. btsx

    btsx Well-Known Member

    Messages:
    223
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #4
    <!--#include virtual="your file here" -->
    Code (markup):
    it may only work if the file extension is shtml or shtm
     
    btsx, Feb 27, 2008 IP
  5. wwe9112

    wwe9112 Guest

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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
     
    wwe9112, Feb 27, 2008 IP
  6. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well to do it with PHP is very easy,

    
    <?php
    include("Path");
    ?>
    
    Code (markup):
     
    nicangeli, Feb 27, 2008 IP
  7. gizah

    gizah Member

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    nicangeli
    I have Pm you some information.Please email me.
     
    gizah, Feb 27, 2008 IP
  8. wwe9112

    wwe9112 Guest

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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?
     
    wwe9112, Feb 27, 2008 IP
  9. Codythebest

    Codythebest Notable Member

    Messages:
    5,764
    Likes Received:
    253
    Best Answers:
    0
    Trophy Points:
    275
    #9
    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
     
    Codythebest, Feb 27, 2008 IP
  10. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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)
     
    nicangeli, Feb 27, 2008 IP
  11. wwe9112

    wwe9112 Guest

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Thats confusing man lol...I'm so lost!
     
    wwe9112, Feb 27, 2008 IP
  12. Codythebest

    Codythebest Notable Member

    Messages:
    5,764
    Likes Received:
    253
    Best Answers:
    0
    Trophy Points:
    275
    #12
    One thing though...footer, navigation and header will be .inc.php and not .php
     
    Codythebest, Feb 27, 2008 IP
  13. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Yes thats correct, my bad, although it does still work with just .php
     
    nicangeli, Feb 27, 2008 IP
  14. wwe9112

    wwe9112 Guest

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    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
     
    wwe9112, Feb 27, 2008 IP
  15. Codythebest

    Codythebest Notable Member

    Messages:
    5,764
    Likes Received:
    253
    Best Answers:
    0
    Trophy Points:
    275
    #15
    Why don't you google it?
     
    Codythebest, Feb 27, 2008 IP
  16. wwe9112

    wwe9112 Guest

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I have been all day now.
     
    wwe9112, Feb 27, 2008 IP
  17. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Dan Schulz, Feb 27, 2008 IP
  18. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #18
    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
     
    kk5st, Feb 27, 2008 IP
  19. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #19
    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 Schulz, Feb 27, 2008 IP
  20. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #20
    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
     
    kk5st, Feb 27, 2008 IP