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.

PHP code in a html page

Discussion in 'HTML & Website Design' started by Abhik, Aug 23, 2008.

  1. #1
    Hello all,
    I need to place a small php code in html page.
    How can I make it working?
    I have tried putting up a .htaccess file with the following lines in it
    AddType application/x-httpd-php .php .htm .html
    PHP:
    and
    AddType application/x-httpd-php .html
    AddType application/x-httpd-php .htm
    PHP:
    But, none of them are working.
    Is there any way out?
     
    Abhik, Aug 23, 2008 IP
  2. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm. Wouldn't it be easier to put html code into .php file and then rewrite the file to .html with mod rewrite?
     
    risoknop, Aug 23, 2008 IP
  3. salihpk

    salihpk Banned

    Messages:
    689
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yeah.Its better to change html file extension to php.So it will work fine.
     
    salihpk, Aug 23, 2008 IP
  4. Joseph S

    Joseph S Well-Known Member

    Messages:
    1,373
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #4
    I have all my stuff as PHP, doesn`t mater if I only use HTML in it :)
     
    Joseph S, Aug 24, 2008 IP
  5. gskesavan

    gskesavan Peon

    Messages:
    428
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Just put the code into the html file.
     
    gskesavan, Aug 24, 2008 IP
  6. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #6
    Cam we see the code? Could be a problem with that...
     
    blueparukia, Aug 24, 2008 IP
    Abhik likes this.
  7. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #7
    That's not possible.
     
    risoknop, Aug 24, 2008 IP
    Abhik likes this.
  8. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #8
    Thanks guys for your responses..
    Anyway, I have managed to do it by calling the php file in virtual mode.
    heres the code I used.
    <!--#include virtual="/filename.php" -->
    HTML:
     
    Abhik, Aug 24, 2008 IP
  9. CGSS-CyberGeek

    CGSS-CyberGeek Peon

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hello,

    Another way in which you could have done this was by editing the php.ini file in your server root to add the .html or .htm as a file to also be parsed by the PHP interpreter.

    But I see you have fixed the problem, congrats!
     
    CGSS-CyberGeek, Aug 24, 2008 IP
    Abhik likes this.
  10. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #10
    That is a SSI directive. Weird that would work on pages that end in .html and not .shtml

    At any rate, I have had the same problem as you before. Cannot explain why, but you could have tried ONE of the following until it works:

    AddHandler x-httpd-php5 .shtml .html .htm
    AddHandler application/x-php .shtml .html .htm
    AddType x-mapp-php5 .shtml .html .htm
    AddType application/x-httpd-php .shtml .html .htm
    
    Code (markup):
    I have used either one of these, depending on what server I am on and what version of php is running.
     
    Dodger, Aug 24, 2008 IP
  11. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #11
    Its a linux box with php5
    tell me which one should I use
     
    Abhik, Aug 24, 2008 IP
  12. imi_99

    imi_99 Peon

    Messages:
    280
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #12
    hmm, it mean there are ways to use php in html
     
    imi_99, Aug 24, 2008 IP
  13. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I am using the following for that setup:

    AddHandler x-httpd-php5 .php .htm .html
    Code (markup):
    I added the .php for good measure. Probably not needed. If you have any .shtml pages, add that extension to the list.

    This is the same directive I use to process Blogger FTP published pages to my server. It has cut down on transfer time immensely when I cut out everything above/below the posts and used include statements. With over 500 posts, it is getting quite large!
     
    Dodger, Aug 24, 2008 IP
  14. auto-loans-ez

    auto-loans-ez Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Hi,
    This is Srinivas Sr. SEO, you rise question is very populated in shat time, in my opinion is you do all those thing php in dream wear and save as in html page. For example index.php is there you want change it index.html, you save as a index.php page to index.html. Because You didn't modify php code into html code.
     
    auto-loans-ez, Aug 24, 2008 IP
  15. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #15
    WTF, are we outsourcing spam now?
     
    Dodger, Aug 25, 2008 IP
  16. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #16
    Yeah.. He is..
    Post reported.
     
    Abhik, Aug 25, 2008 IP
  17. kéké

    kéké Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Isn't it weird that you have to put PHP in HTML page ?

    HTML is for non-dynamic page isn't it ?
    Could you tell me why you needed doing HTML better than PHP file ?

    Kéké : (please excuse my english as it is a foreign language to me)
     
    kéké, Aug 25, 2008 IP
  18. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Keke,

    There are two reasons for processing php script inside of a page that ends in .html

    It used to be that .html pages were considered static. Some genius, don't know who, figured out that you could instruct the server to process those pages as if they were .php pages. It was also mistakingly believed that static pages would garner better SERPs, a myth that propagates thru forums and blogs even today.

    The main reason for doing this is to ease site maintenance. You can now "include" other files within your .html pages, such as the start of a page (head) and the end of the page (tail). These areas are usually the same from page to page and now can be maintained in a single file for each section.
     
    Dodger, Aug 25, 2008 IP
  19. kéké

    kéké Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Oki,

    I didn't heard about that myth ... Thas good indeed for me, as I prefered spending my time on writting more intersting information on my pages than spending time looking for that kind of technics.

    I'm using that include things for Meta data such as the last revision time, language, and other basic information.

    Thanks a lot for answering me so quickly and in a way I can understand ^^.

    have a good day.
    kéké
     
    kéké, Aug 26, 2008 IP
  20. sjlogan88

    sjlogan88 Peon

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I make all my sites with a php extension even if I don't use any on the page. Just incase you need to come back and add something requiring PHP
     
    sjlogan88, Aug 26, 2008 IP