slpctrl Posted September 5, 2008 Share Posted September 5, 2008 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 ), 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 More sharing options...
BlueSkyIS Posted September 5, 2008 Share Posted September 5, 2008 when the user submits their guess, see if the md5() of it matches the value of $_SESSION['str'] Link to comment https://forums.phpfreaks.com/topic/122904-one-more-question-about-captcha/#findComment-634763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.