Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How do I embed php in html

Discussion in 'General Discussion' started by TrafficProducer, May 19, 2006.

  1. TrafficProducer

    TrafficProducer Registered

    Joined:
    Sep 10, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    151
    :rolleyes:

    How do I embed php in html

    I've tried the below in the .htaccess but it does not run the php

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

    The call in a html page is:-

    <?php
    include_once("http://ns1.openhsp.biz/~acomput/apf4/amazon_products_feed.cgi?SearchIndex=Books&BrowseNodeName=Books");
    ?>

    Note, I need to change my domain name Nameservers to point to this.

    Thanks

    http://www.comparebargains.com/books.html

    Needs to call this:-

    http://ns1.openhsp.biz/~acomput/apf4/amazon_products_feed.cgi?SearchIndex=Books&BrowseNodeName=Books
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    166
    There should be no need to parse .htm and .html files with PHP.

    Why do you believe you need to do this?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    168
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    There is nothing wrong with parsing html with php if you have the need to. We have several sites that do exactly this.

    if you are not running phpsuexec then you can add these lines to the virtual host entry in the httpd.conf.

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

    If you are running phpsuexec then its a 2 step process

    first you will need to add .htm and .html as server-parsed in the apache handlers section of cpanel

    then add these entries to the .htaccess file

    AddHandler application/x-httpd-php .htm
    AddHandler application/x-httpd-php .html
    AddType application/x-httpd-php .htm
    AddType application/x-httpd-php .html
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    168
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    The way to embed PHP into HTML is to rename the file to .php, then it will all just work. Seriously, why re-invent the wheel?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    168
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    why reinvent the wheel is why we parse some html through php due to the fact if you change the file extension from .html to .php then you have to redo all page links and on a large site this can consist of having to edit several hundred pages. Lot easier to modify the php/apache engine to parse the .html through php.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    168
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Fairy nuf, thought if I probed a little we might get a reason! :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    166
    However this is only really a workaround to compensate for a poor URL structure.

    If your URLs are of the form http://example.com/directory/ then you could have http://example.com/directory/index.html or http://example.com/directory/index.php or http://example.com/directory/index.cgi etc.

    You shouldn't really have to concern your users with which server-side technologies you're using. Why should your choice of server-side techonologies affect your URLs?

    URLs of the form http://example.com/directory/ are just that little bit easier to recall (rather than trying to remember if the extension was .html, .php, .phtml, .etc) and it then allows you to use whatever server-side technologies you like without breaking all your links.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. dave9000

    dave9000 Well-Known Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    1
    Trophy Points:
    168
    Location:
    arkansas
    cPanel Access Level:
    Root Administrator
    I agree on your point however some people like to use frontpage navigation and themes etc with embedded php as a few of our customers use. Also one of our sites uses web pages linked into standalone exe's that have been in use for 10 yrs. In our case its a lot easier to modify the 1 website to our existing software base than to modify the site and the software just to keep page extensions proper
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice