PHP footer in html template? Please help.

18 replies
Hello, I'm not a coding expert so I want to know if anyone can give me any advice as to what I should do.

I'm editing a template that I bought for a website fr a client. Now the problem is that this template is all HTML and if you wish to make a change to the header and the footer you have to make that change in all the pages of the html.

I want to know how I can put my current footer in a .php file and include that in the html page.

I've been reading online about how I'm able to do this, but it just doesn't work.

Maybe because I'm just copying the html code from the footer page and pasting it on the php file.

This is the current footer code:


It's in a footer.php file. What am I ding wrong.
#footer #html #php #template
  • Profile picture of the author benz
    You need to use .php and not .html as you file extension as you would need to call up the php include() function something like <?php include("footer.php"); ?> on your web pages
    Signature
    herb gardening if you're into greens
    also check out forex trading
    {{ DiscussionBoard.errors[2810377].message }}
  • Profile picture of the author RealSocialSignals
    What do you mean?

    The file which I'm putting the footer in is: footer.PHP

    But the index is .html and not .php

    So it can't be done?
    {{ DiscussionBoard.errors[2810677].message }}
  • Profile picture of the author lknielsen
    It CAN be done, but you must change index.html to index.php this is because you have PHP code in your index file so it must have a .php extension.
    {{ DiscussionBoard.errors[2811143].message }}
  • Profile picture of the author RealSocialSignals
    That's it? I'll give it a try.
    {{ DiscussionBoard.errors[2812657].message }}
    • Profile picture of the author orvn
      Originally Posted by Ardit.WM View Post

      That's it? I'll give it a try.
      That's it.
      Signature
      Orun Bhuiyan[@orvn] [linkedin] See what I've been doing lately by visiting my marketing agency's site. SEOcial specializes in content marketing and integrated optimization. We create conversions for businesses by gracefully connecting the realms of design, development and marketing.

      {{ DiscussionBoard.errors[2813166].message }}
      • Profile picture of the author ram07
        Hi,

        still you can include the footer.php in your index.html....

        There is a way to make php to work in your html and htm pages...

        Just add any one of the line in your .htaccess file that support,

        For web servers using PHP as apache module:
        AddType application/x-httpd-php .html .htm

        For web servers running PHP as CGI:

        AddHandler application/x-httpd-php .html .htm


        Thanks.......
        {{ DiscussionBoard.errors[2814243].message }}
        • Profile picture of the author phpbbxpert
          Originally Posted by ram07 View Post

          Hi,

          still you can include the footer.php in your index.html....

          There is a way to make php to work in your html and htm pages...

          Just add any one of the line in your .htaccess file that support,

          For web servers using PHP as apache module:
          AddType application/x-httpd-php .html .htm

          For web servers running PHP as CGI:

          AddHandler application/x-httpd-php .html .htm


          Thanks.......

          You should not do this!
          You are essentially opening a can of worms with security in the fact that HTML files are not typically guarded for the type of security that PHP files are eg(execution, cmd, etc...)

          Do as mentioned earlier, change the index to index.php and include the footer with an include("footer.php")
          {{ DiscussionBoard.errors[2814328].message }}
          • Profile picture of the author orvn
            Originally Posted by phpbbxpert View Post

            You should not do this!
            You are essentially opening a can of worms with security in the fact that HTML files are not typically guarded for the type of security that PHP files are eg(execution, cmd, etc...)

            Do as mentioned earlier, change the index to index.php and include the footer with an include("footer.php")
            Good call- I was about to mention the same potential issue.
            Signature
            Orun Bhuiyan[@orvn] [linkedin] See what I've been doing lately by visiting my marketing agency's site. SEOcial specializes in content marketing and integrated optimization. We create conversions for businesses by gracefully connecting the realms of design, development and marketing.

            {{ DiscussionBoard.errors[2817258].message }}
            • Profile picture of the author espradley
              Originally Posted by orvn View Post

              Good call- I was about to mention the same potential issue.

              I don't think its a security issue. If you read what appache is doing:
              Code:
               
              AddType application/x-httpd-php .php .html
              it's changing the way the actual file is run.

              I work for a 10 mil/year company and we have this setup.

              It makes things harder though because when you open the files in WYSIWYG editors it uses the color coding and rules from HTML....a bit frustrating at times.

              I've never heard of it causing security holes however... But it's still a pain.
              Signature

              Eddie Spradley

              {{ DiscussionBoard.errors[2817741].message }}
  • Profile picture of the author icun
    Like they said, simple.

    Rename index.html to index.php, change any links that point to it and make sure footer.php is in the same directory as index.php

    Then just have this line where you want the footer:

    <?php include("footer.php");?>
    {{ DiscussionBoard.errors[2815039].message }}
  • Profile picture of the author icun
    I wouldn't recommend changing your HTML files so they can use PHP and still have a .html extension unless you had a very specific reason for it and knew what you were doing.
    {{ DiscussionBoard.errors[2815044].message }}
  • Profile picture of the author jbrewski
    I didn't know the .html extension still existed, haha.

    I would strongly recommend using either .php or .asp if you are wanting to do includes/requires.

    PM me if you still need any assistance!!
    {{ DiscussionBoard.errors[2815475].message }}
  • Profile picture of the author espradley
    Keep in mind, HTML has an include feature too.

    <!--#include virtual="insertthisfile.html" -->

    But these guys are all right. Convert over to the .php extension.

    And where it is perfectly safe to use the .htaccess method to treat your .html files as php files, it's sort of the long way of doing things. I'd recommend if you were a programmer, but not for someone just trying to wing it.

    Read up about all the different include methods in the link below.

    WWW FAQs: How do I include one HTML file in another?
    Signature

    Eddie Spradley

    {{ DiscussionBoard.errors[2816482].message }}
  • Profile picture of the author thai
    I recalled from a few php templates I edit. I saw most of the <?php include("filename.inc");?> which I assume .inc stands for include file. Does it matter to use .php or .inc extension in the include function?
    Signature
    My Ultimate Goals:
    1. Make $100 Per Day with Auto Blogging Software
    2. Give Away *Make Money Selling Nothing* eBook
    3. Lose Weight & Get Six Packs Abs
    4. Update Earning Daily at http://100perday.biz
    {{ DiscussionBoard.errors[2817376].message }}
  • Profile picture of the author phpbbxpert
    .inc extension is not a very common practice anymore.
    They were typically configuration/settings files.

    Just about every framework out there sticks to straight .php extension.
    I suggest doing the same unless there is a specific reason for using it.
    {{ DiscussionBoard.errors[2817395].message }}
  • Profile picture of the author RealSocialSignals
    Thanks people! I'll be implementing this as soon as possible! (the renaming of .html to .php)

    I will update you all! Thanks tons!
    {{ DiscussionBoard.errors[2817652].message }}
  • Profile picture of the author kalens99
    You can make a homepage a PHP file. In fact that is usually what I do. CMS software like Joomla and Drupal usually do this by default.
    Signature

    Original Reports Compact With Empirical Data on Creating a Solid IM Strategy - Stop Reading Bogus Theories
    Internet Marketing Strategies
    Free Report 11 Biggest Mistakes marketers make

    {{ DiscussionBoard.errors[2827870].message }}
  • Profile picture of the author RealSocialSignals
    Ok it worked perfectly! Thank you all soooooooooooo much!!!!!!
    {{ DiscussionBoard.errors[2843067].message }}

Trending Topics