1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

header body footer script in php for website

Discussion in 'PHP' started by finaldestination, May 15, 2006.

  1. Pietercornelis

    Pietercornelis Guest

    Messages:
    631
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #21
    Not to steal your thread, but I'm having trouble combining absolute url's with the php include statement, it doesn't display when I use:

    <?php include("http://www.all-history.com/header.php"); ?>

    But it does when I use:

    <?php include("header.php"); ?>

    Could someone elaborate on the stuff already told in this thread?
    Thanks in advance.
     
    Pietercornelis, Jan 3, 2007 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #22
    You need to use the file path in an include.

    For example yourname/public_html/includes

    And in answer to the other question html files can include php code if you use htaccess to alter the way the server parses them.
     
    mad4, Jan 3, 2007 IP
  3. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    would you recommend doing it that way? an can i take info from databases with this method?
     
    The Evil Penguin, Jan 3, 2007 IP
  4. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #24
    anyone????
     
    The Evil Penguin, Jan 3, 2007 IP
  5. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #25
    Yes, thats the way to do it.
     
    mad4, Jan 4, 2007 IP
  6. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #26
    k thanks dude
    i owe you one
     
    The Evil Penguin, Jan 4, 2007 IP
  7. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #27
    <?phpinclude("header.php");?>body content here<?phpinclude("footer.php");?>
    PHP:
    one final question. if i decide to actually just use php, would i postition where the header goes in the header.php or in the main page? can i have the header in a table?
     
    The Evil Penguin, Jan 4, 2007 IP
  8. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #28
    The idea of headers and footers are to move the content that stays the same on every page from the main page files into external files.

    Why not try it out rather than asking here?
     
    mad4, Jan 5, 2007 IP
  9. srinu123

    srinu123 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #29
    you can use smarty .u get the what would like.
    otherwise
    you can u includes files of header and footer .
     
    srinu123, Jan 5, 2007 IP
  10. Pietercornelis

    Pietercornelis Guest

    Messages:
    631
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #30
    Hmm. I still can't figure it out. If I use httpdocs/header.php it still doesn't work. How exactly does this filepath work? Where do you begin and where do you end?
     
    Pietercornelis, Jan 5, 2007 IP
  11. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #31
    why spend alot of time trying to do something im not even sure is possible, when i can just come here and ask for the answer. this is the purpose of this board, is it not?

    now on a side note, i make most of layouts and templates in tables, can i put php files into a cell of a table?
     
    The Evil Penguin, Jan 5, 2007 IP
  12. EvilivE

    EvilivE Peon

    Messages:
    23
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #32
    The filename can be absolute or relative. Assuming a *nix environment here is a working example:
    
    /
    + var/
             + www/
                       header.html
                       footer.html
                      + public_html/
                                        index.php
    
    Code (markup):
    From index.php you can include header.html and footer.html one of these two ways:
    include("/var/www/header.html");
    include("/var/www/footer.html");
    PHP:
    or like this
    include("../header.html");
    include("../footer.html");
    PHP:
    HTH
     
    EvilivE, Jan 6, 2007 IP
    Pietercornelis likes this.
  13. EvilivE

    EvilivE Peon

    Messages:
    23
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #33
    absolutely.
     
    EvilivE, Jan 6, 2007 IP
  14. EvilivE

    EvilivE Peon

    Messages:
    23
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #34
    In the main page.
     
    EvilivE, Jan 6, 2007 IP
  15. EvilivE

    EvilivE Peon

    Messages:
    23
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #35
    It was made one of two ways.

    A) They are actually static html files

    or

    B) In order for a file to be processed by the php interpreter the web server needs to configured in such a manner that it knows what file extensions are to be sent to php. Which means you can configure any file extension to be sent to php, it does not have to have a .php extension. If you wanted file extensions with .evilpenguin to be processed by php, you simply configure your web server to handle them that way. In the website that you gave as an example, I would not suggest to send .html files to php. The reason why not is because every .html file would be sent to php regardless if it had any php code or not. Which in turn means that your pages are not being served as fast as they could because they need to be parsed by the php interpreter prior to rendering.

    HTH
     
    EvilivE, Jan 6, 2007 IP
    The Evil Penguin likes this.
  16. Pietercornelis

    Pietercornelis Guest

    Messages:
    631
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #36
    Thanks a lot! I only had to figure out what prefix I had to use! It was actually quite simple...:S
     
    Pietercornelis, Jan 6, 2007 IP
  17. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #37
    thanks mate, rep added
     
    The Evil Penguin, Jan 6, 2007 IP
  18. scriptur

    scriptur Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #38

    put this code in a php page, say info.php :

    <?php
    echo phpinfo();
    ?>

    when you load the page, you can see the proper filepath that you need to use
     
    scriptur, Jan 7, 2007 IP