How can I run a PHP script on my HTML page?

Armughan October 26, 2011
Pinterest Stumbleupon Whatsapp

I just read your article How To Create & Edit The .htaccess File For Your Site How To Create & Edit The .htaccess File For Your Site How To Create & Edit The .htaccess File For Your Site Read More . I have a similar issue.

I want to run a PHP script on a html page. There is a website xcommentpro.com which provides comment services for a website. There are two options to place comment on my html site, either I change my web page extension to .php or I configure my .htaccess file. Please visit this page and see the code to be placed in .htaccess file.
http://www.xcommentpro.com/htaccess-instructions.php

I dont know how and where to place the code in above the above page in my .htaccess file.

I contacted my hosting company regarding this issue, they are saying that I simply edit the Apache Handlers section in control pannel. I dont know how to do that either. They were telling me to add x-httpd-php in the headler field and .html in the extension field. I have done that but still I’m unable to run a .php script on my page.

Ads by Google

  1. Anonymous
    January 16, 2012 at 12:40 pm

    shame your hosting comapny couldn't do it for you maybe you should switch to a kinder one.

  2. Jaimon
    January 9, 2012 at 1:43 pm

    Hello  there ,  I  have  the  same  problem ,  I  have  an  HTML  website , and  want  to  run a link  in PHP ,  i  have  tried  everything  that  i know off  to overcome  this  problem but  I am  afraid i can't manage  it , can someone  please  help  me  in this  problem ?  i  have  a FileZilla ,  and  I  could not  find  the  root directory like  the message  below  says , where  do  i  find  this  root  directory ? and  any advice on the matter  will  be  really  helpful , thank you 

  3. Jay
    October 27, 2011 at 3:31 am

    If i got it right, They are telling you to find *.htaccess file, and add those two lines to the file,
    or create an *.htaccess file and add those two lines. and save it, and add to the folder where the html fileson which you want to use the comments are stored.

    you can do this with notepad.
    edit the file with notepad, or create a text file with notepad, add those two lines, and save it as htaccess file.
    and upload on that folder yopu want to use comments.

    htaccess is the extension of the file. file name can be xyz.htaccess.
    it is a per direcory configuration file. to manage permissions.

    editing htaccess file can cause errors, i am not sure about adding new file will cause errors or not.
    There is one more option :

    Try Disqus, many websites including makeuseof.com are using disqus.
    http://www.disqus.com

    It is used by all, so it may be easy to manage.
    And people on Makeuseof can guide you also.

    it contains the instructions to use disqus on your site, avoid the blogger par of the article, it also has a version of javascript based version which you can use on any platform :
    http://www.bloggertipandtrick.net/2011/03/add-disqus-comment-system-to-blogger.html

  4. Jeff Fabish
    October 27, 2011 at 1:26 am

    Your host should offer a built in FTP interface, if not install FileZilla, then connect. Once connected, find your ".htaccess" file and download it. Your htaccess file should be located in the root directory (top most). Now that you've got the htaccess file, open it up in notepad and simply add thosetwo lines into the text file (anywhere should be fine). Save the file and reupload it to the root directory.

    If you do not see your .htaccess file, your host may have it stored in an absolute path which may not be visible to you. In which case, post your host and I'll see if I can figure out the control panel and help you get set up. 

    This is an unorthodox method of using PHP. You should simply save your files (that you want to use PHP in) as something.php. You can then add HTML and PHP into the source file and upload it like you normally would. An example of PHP and HTML in the same file is below

    <html>
    <head>
    <title>PHP and HTML</title>
    </head>
    <body>
    <h1>Hello <?php
    echo "Armughan";
    ?>
    </h1>
    </body>
    </html>

    Tizag - PHP Tutorial
    W3Schools - PHP Tutorial
    Zend - PHP Tutorial