Jump to content

One more question about CAPTCHA


slpctrl

Recommended Posts

Alright, here's my code to produce my image for the captcha:

 

<?php
session_start();
$str1 = md5(microtime() * mktime());
$str = substr($str1,0,5);
$captcha = imagecreatefrompng("./captcha.png");
$black = imagecolorallocate($captcha,0,0,0);
$line = imagecolorallocate($captcha,rand(0,250),rand(0,239),rand(0,240));
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imageline($captcha,rand(0,50),rand(0,100),rand(0,200),rand(0,200),$line);
imagestring($captcha,rand(1,5),rand(0,100),rand(0,50),$str,$black);
$_SESSION['str'] = md5($str);
header("Content-type: image/png");
imagepng($captcha);
?>

 

But now, how would I check if the text submitted matches the text on the captcha? I know this question might seem dumb I donno, I haven't done any PHP in a while (been learning lots of python lately :P), and can't get my head around how to check. Any help is appreciated thanks.

Link to comment
https://forums.phpfreaks.com/topic/122904-one-more-question-about-captcha/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.