Seach Field Inside A .html File.

Discussion in 'PHP' started by darkloshean, Feb 19, 2013.

  1. #1
    I'm trying to make a php search engine on my web side, but the search field will be place at the header on every page on my website and not just in one single serach.php page.

    So at my index.html i will start with code with:
    <?php
    //my code
    ?>
    Now my question is, will the php script work if i still save the file as index.html? or do i need to change it to index.php to allow the php script to work. If so, does it mean that i have to save my entire website as php, since the search field will paced at the header trought all the pages. If thats the case, is it any way to embed or run a php script and still call the file .html?
     
    darkloshean, Feb 19, 2013 IP
  2. eldiablo

    eldiablo Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    80
    #2
    You have lot of solutions for that. I can mention 2 possible solutions...

    You can have your website coded entirely in .php and use .htaccess rewrite to rewrite all your files from .php to .html

    On the other hand you can tell your server to run your .html files as .php files so that you can execute .php even if file is .html simply add this to your .htaccess file and it should work:


     
    eldiablo, Feb 19, 2013 IP
  3. darkloshean

    darkloshean Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    I rather code my page in html so the seccond solutions would be best for me.
    thanks for your answer,appreciate it :)
     
    darkloshean, Feb 19, 2013 IP
  4. sdeveloper

    sdeveloper Member

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    31
    #4
    Create a .htaccess file at the root of your website and add this line:
    AddType application/x-httpd-php .html .htm
    Code (markup):
    If your are running PHP as CGI (very unusual configuration), you should write instead:
    AddHandler application/x-httpd-php .html .htm
    Code (markup):
     
    sdeveloper, Feb 21, 2013 IP