Forum Moderators: coopster

Message Too Old, No Replies

Image Verification

         

rysolag

1:24 am on Oct 19, 2004 (gmt 0)

10+ Year Member



Does anyone know of a tutorial on how to implement an image verification system on a registration page? i.e. something to block spiders or bots from registering 1000 times in 1 sec.

thanks

rysolag

1:25 am on Oct 19, 2004 (gmt 0)

10+ Year Member



im using PHP

Cook

2:05 am on Oct 19, 2004 (gmt 0)

10+ Year Member



You can use PHP's GD extensions to create an image with a random string in there that registering users would have to enter to validate the creation of their account.

Something along the line:


<?php
header("Content-type: image/jpeg");
$im = @imagecreatetruecolor(100, 50);
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A random string", $text_color);
imagejpg($im, '', 75);
imagedestroy($im);
?>

Where A random string is replaced with an actually random string.

rysolag

4:23 am on Oct 19, 2004 (gmt 0)

10+ Year Member



question about the call to header():

can use this - remember this has to be in a real web page i.e. text and tags and forms and all that great stuff.

thanks

mincklerstraat

6:34 am on Oct 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thing is, this is the image. It's not in the middle of a php file somewhere, 'oh we need to make the image, cut and paste that script', no. It's in it's own file. So you get this image on your page with something like <img src="imagescript.php?parameter=whatever" /> (parameter there in case you need it - don't if you use cookie - based sessions - you can use your own special code to encode / decode parameter). All web resources have mime types (or content types), and php by default sends out headers telling your browser that what's coming is text/html. For images, you need a Content-type header telling browsers it's an image, and what kind.

rysolag

7:41 am on Oct 19, 2004 (gmt 0)

10+ Year Member



very interesting...never thought to assign the img src to a php script.

neat. everyhthing's clear now.

took me 4 forums and 20 posts to get this answer.

thank you!