Add php captcha to .html page

by Ateeq Rafeeq, September 16, 2014

If we have a website which have all pages extension .html means they are html pages we need now to put captcha on this site but we are worried cause javaScript captcha can be disabled easily while php captcha make sure spam is not going through the form. While we do not want to use javaScript captcha as that can be disabled very easily and we have to use php captcha in html web page. This can be easy to do by changing .html extension of file to .php but that can be a problem as many other sites can have link to our .html page and google rank or other search engine ranks and the links we posted previously on social media can go broken or 404 errors.

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.

Add reCaptcha

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.


Follow Us

Popular Posts

Webful Creations Vision

All rights reserved