Run php code in html page
Best way to do run php code in html page by guiding server through .htaccess file that if .html file contains <? or <?php php tags then execute them rather to display as html. Once we are able to do this we can easily use php captcha in our html contact form or html page with .html extension. Here how we can do it.
First of all check if your server already have .htaccess file in same directory where the .html is. If so download that file and edit file to insert new code which will make it running captcha php code.
If .htaccess file does not exist already kindly create a new file and make sure its .htaccess if you are using notepad to do this make sure you are not saving it like .htaccess.txt that would not run.
So now you have created new .htaccess file or you are editing existing .htaccess file. In top line of new file please insert the following code this code will tell server everything .html file execute to find php code in that file and execute server side that code. if your pages are .htm please change .html to .htm in following code.
AddType application/x-httpd-php .html Or for .htm AddType application/x-httpd-php .htm
For detailed reference on making php work inside html file refer to this post as well.
Google reCaptcha is best option to use and its very easy to implement as well. Please visit google reCaptcha site and checkout how to place that in html site. That’s all you have to do it.