Posted at Oct 22, 2009 7:06:05 AM by Ronald Busky | Share
With all the captcha's out there right now why would anyone reinvent the wheel and write another one. Well I did and here is why.
When I build forms, my go-to validation is 9 out of 10 times its jQuery plugin: Validation. Keeping with that and their built in functionality to basically = something to something. I used that to my advantage and use PHP to create a simple captcha.
How it works
Let's start with what you will need. 1. A Form, 2. The PHP, 3. The jQuery. Cool we got that? let's move on.
Lets begin with the simple PHP that builds the math
Here we are basically setting two different numbers (randomNum and randomNum2) and getting their total in (randomNumTotal). You can read up on the rand() php function, but basically what it's doing here is giving me a random 1 digit number from 0-9.
Now we need to set up our jQuery pieces. so here is what you would need to include inside of your <head> tag.
And thats pretty much it. I would pressume that this can be changed for a bunch of other uses. maybe creating an array of the alphabet. selecting 1 letter, then the letter that follows and having the answer be the one after that (ex: A,B -- answer: C). Or selecting two letters that are one letter apart and having the user select which one is in the middle (ex: A,C -- answer: B).