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.

Anybody know how to add PHP code into a HTML file

Discussion in 'Programming' started by rcajht, Jan 19, 2007.

  1. #1
    I tried several times, it not works.
    but if I insert code by using Iframe, it works.
     
    rcajht, Jan 19, 2007 IP
  2. sukantab

    sukantab Well-Known Member

    Messages:
    2,075
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    110
    #2
    It will not. If the extension is .htm or .html, it will not work.
    Change the extension of the file to .php and shurely it will work.
     
    sukantab, Jan 19, 2007 IP
  3. iisbum

    iisbum Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Depending on how much control you have over your server, you can tell it to run .html file thru the php engine.
     
    iisbum, Jan 19, 2007 IP
  4. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the only way u can do is through .htaccess u should make a code wch says .html to act like php
     
    koolasia, Jan 20, 2007 IP
  5. -bank-

    -bank- Well-Known Member

    Messages:
    674
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Open the .htaccess file in the folder where you have your site, then add:

    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    Code (markup):
    Then just use php as normal, for example:

    
    <?php
    if ($user = 'rcajht') {
    echo 'welcome rcajht to your website';
    }
    else {
    welcome to our website
    }
    
    PHP:
    Hope that Helps
    }
     
    -bank-, Jan 20, 2007 IP
    bilirkishi likes this.
  6. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Read Bunk's post. It's possible, but you have to alter the apache config just a little bit. If you're going to do a lot with PHP and it's not just one simple little code (or even if it is), renaming your file from like index.html to index.php might be a good idea. That way if you ever move your server, or have someone looking at your code, it's a bit smoother and causes less confusion.
     
    projectshifter, Jan 21, 2007 IP
  7. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah, it's really just easier to change the file extension.
     
    rgchris, Jan 22, 2007 IP