If you are a do-it-yourself programmer and you want to know how to add image validation to a form on your web site then this is the article for you. While there are many ways to do this, if you follow these steps, you will learn the easiest way to get the job done. Once you have mastered the example here, you will have all the concepts and experience you need to incorporate the final product into your form on your website.
We will need two files. The first file will create the validation image and incorporate the image in a validation form. Here is the step-by-step code for the first file: verify.php
— BEGINNING OF FILE: VERIFY.PHP —
Type in the validation code from the image. (Case sensitive)
— END OF FILE: VERIFY.PHP —
Now we will create a file that will perform the validation using the POST method:
— BEGINNING OF FILE: VALIDATEFORM.PHP —
— END OF FILE: VALIDATEFORM.PHP —
IMPORTANT NOTE: Because many free article websites do not support HTML in the body of the article the files above will not work unless you eliminate the space after. Just do a find and replace all.
That is really all there is to it. You probably noticed that I also went to the trouble of including the DOCTYPE and charset lines in this simple example. I did this as a little reminder to make sure that all of your pages on your website are W3C compliant. One of the biggest mistakes that many webmasters make is to neglect W3C compliance on their web pages. If your web pages are not W3C compliant you will get low search engine rankings. Even worse, if you are advertising, your ads may not be as relevant as they should be! In my other article, I explain W3C compliance and the most common mistakes.
Copyright 2006 David Picella