tpsilver10 Posted May 4, 2007 Share Posted May 4, 2007 So I'm trying to integrate a CAPTCHA field into my current form. I've got this going, but it only ever comes back with 'Wrong Code' - the code is never right... This is input part. <form action="process.php" method="post" /> /* The Form */ <img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /> <br /><br /> Security Code: <input name="verif_box" type="text" id="verif_box" class="formstyles" /> <br /><br /> <input type='submit' value='Submit Form' class="formstyles"> <input type=reset value='Clear Form' class="formstyles"> This is the processing bit. <?php $verif_box = $_REQUEST["verif_box"]; // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ process_form(); setcookie('tntcon',''); } else { echo "Wrong Code"; exit; } //Rest of the form ?> The verification image: <?php header('Content-type: image/jpeg'); $width = 50; $height = 24; $my_image = imagecreatetruecolor($width, $height); imagefill($my_image, 0, 0, 0xFFFFFF); // add noise for ($c = 0; $c < 40; $c++){ $x = rand(0,$width-1); $y = rand(0,$height-1); imagesetpixel($my_image, $x, $y, 0x000000); } $x = rand(1,10); $y = rand(1,10); $rand_string = rand(1000,9999); imagestring($my_image, 5, $x, $y, $rand_string, 0x000000); setcookie('tntcon',(md5($rand_string).'a4xn')); imagejpeg($my_image); imagedestroy($my_image); ?> Link to comment https://forums.phpfreaks.com/topic/50047-new-php-captcha-issue/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.