HTML and PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isa
    Registered User
    • Dec 2002
    • 24

    #1

    HTML and PHP

    Hi guys,
    how can I invoke a PHP script form my HTML pages ?
    I'm using <!--include virtual="/php/myphp.php"--> but it slows down my server. Unfortunately I have thousand of HTML pages and I want to display a specific banner on them through a PHP script.
    Any suggestion ?

    Thanks and kisses
    Isa
  • keyDet79
    Confirmed User
    • Feb 2003
    • 1109

    #2
    So you want to display a header/footer?

    PHP Code:
    Some HTML Code here for the Header
    
    <?
    if (isset($_GET['page'])) {
      $page = $_GET['page'];
      if (file_exists("$page")) { include("$page"); }
      else { include("404.html"); }
    }
    else { include("main-page.html"); }
    ?>
    
    Some HTML Code here for the Footer
    Put this into index.php, you can then execute it like server.com/?page=file.html

    And it will display the header, then file.html, then the footer.

    If you just want to include some code in the page itself you can do so with SSI (server side includes) by adding an ssi line of code into each html file.
    Last edited by keyDet79; 04-29-2003, 05:56 AM.

    Multihomed quality BW for less
    ICQ 51034232 - MSN [email protected] - Email keydet(at)vibehosting.com

    Comment

    • isa
      Registered User
      • Dec 2002
      • 24

      #3
      Thanks guy but that's what I don't want to use. My pages are .HTML and I would not use SSI directives because they slow donw my server.
      Any other suggestion ?

      Thanks
      Isa

      Comment

      • cj-design
        Confirmed User
        • Apr 2003
        • 378

        #4
        Hey,

        I dont think there is anyway you can use .html extensions for php code unless you edit your php ini file.

        However, I have come up with a solution:

        Most servers will only parse files ending in .shtml for Server Side Includes. You may not wish to use this extension, or you may wish to retain the .htm or .html extension used by files prior to your changing the site and using SSI for the first time.

        Create a file called .htaccess (u may need to create a file called htaccess.txt then rename it once uploaded) Add the following to your .htaccess file within your main folder (where index.html is):

        AddType text/html .html
        AddHandler server-parsed .html
        AddHandler server-parsed .htm

        upload the .htaccess file and insert this code where you want your php banner code to display:

        < !--#include virtual="/banner/banner.php" -->

        < !--#exec cgi="/banner/banner.php" -->

        Note: Make sure you add remove the spaces between < and !

        All the SSI command is doing is executing the php script.

        If that doesnt help/work you'll have to edit .html as an extension to "parse" with php
        Last edited by cj-design; 04-29-2003, 03:40 PM.

        Comment

        • cj-design
          Confirmed User
          • Apr 2003
          • 378

          #5
          forgot to mention that you display either the include OR the exec, depending on which one works (try include first, its the usual one)

          Comment

          • foe
            Confirmed User
            • May 2002
            • 5246

            #6
            use i frames or hahahahahahahahahaha or ssi

            Comment

            • foe
              Confirmed User
              • May 2002
              • 5246

              #7
              j a v a s c r i p t

              Comment

              Working...