Hey guys,
How can I add CAPTCHA in a regular .php mailform ?
Printable View
Hey guys,
How can I add CAPTCHA in a regular .php mailform ?
Uh... that's complex.
You need to use the GD library to dynamically generate an image based on input and then later compare that original input to what the user types. Furthermore, you need to create it with distortion so a computer can't read it.
As I said, complex.
You could alternatively have images you created by hand (say 10 of them might work for a small site) and corresponding 'correct' values for them that would later be matched. Be sure never to output that value, just keep it secure in the php code.
Read this thread.
http://chovy.dyndns.org/php/captcha.php
just did this one in a few hours. although most of that time was looking for a TTS library.
It's probably not worthy of a high-traffic site, as I'm not tweaking the text or background (yet anyway).
Most decent servers already have a GD library installed, and I found a nice little file that will tell you, you can download it below.
Just rename it to gd-test.php, upload to your domain, browse to the page and view the results. If you have it then no need for all the extra worrying :D
Thanks guys.
What code do I need to add to the mailform ?
what language is it in?
html sending to a php
Festival will serve your purposes. Run it against a Sable XML file or a Scheme script, not just plain text: this will allow you more control over the factors required for transformation.Quote:
just did this one in a few hours. although most of that time was looking for a TTS library.
It won't even provide a barrier. There are freely-available CAPTCHA breakers out there that will crack that with a 100% success rate in milliseconds.Quote:
It's probably not worthy of a high-traffic site, as I'm not tweaking the text or background (yet anyway).
What code do I need to add to the mailform in order to get a capcha ? The form is made in .html submitting to a .php.
Mike wrote in another thread that this could replace a captcha
But how do I place this ? In a .php ?Code:$texts = array("el301kfs","s94kf9ds","si340fsk","4iogfd0h","49ffle95","fo40fsl4","903mvlsmf");
$rand = rand(0,count($texts)-1);
header("Content-type: image/png");
$im = @imagecreate(80, 50)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 2, 6, 5, $texts[$rand], $text_color);
imagepng($im);
imagedestroy($im);
create a file called captcha-image.php
That is a very basic CAPTCHA. It will present no trouble whatsoever to bots, and will stop blind people from accessing your site.
How can blind people access a computer anyway? Do they have special keyboards?
So I save the above code as capcha-image.php. Do I place <?- before it ?
And what code do I add in the form to see this .php file ?
Why would they need special keyboards? There's nothing to stop a blind person from typing, or even from learning to type (so long as some form of feedback is given telling them which key they're pressing).Quote:
How can blind people access a computer anyway? Do they have special keyboards?
Text-to-speech technologies help a lot.Don't bother. As I said above, the above script might as well not be there, and will cause more problems than it will solve.Quote:
So I save the above code as capcha-image.php. Do I place <?- before it ?
And what code do I add in the form to see this .php file ?
Another solutions, if I wish to place captcha ?
i think the basic problem there is that it uses only white and black.