Imad Posted March 28, 2008 Share Posted March 28, 2008 Hi Guys, I need help with CAPTCHA. I created the captcha as shown below: <?php session_start(); $encrypt = md5(mktime() / time(myds) * microtime()); $string = substr($encrypt,0,; $cap= imagecreatefrompng("cap.png"); $black = imagecolorallocate($cap, 0, 0, 0); $grey = imagecolorallocate($cap, 105, 105, 105); $four = imagecolorallocate($cap,233,239,239); imageline($cap,0,0,39,29,$black); imageline($cap,15,40,79,9,$four); imageline($cap,18,34,70,3,$grey); imageline($cap,23,39,76,9,$grey); imageline($cap,80,30,50,0,$grey); imageline($cap,90,50,70,0,$grey); imageline($cap,90,50,93,0,$grey); imagestring($cap, 10, 25, 15, $string, $black); $_SESSION['key'] = md5($string); header("Content-type: image/png"); imagepng($cap); session_start(); ?> I then called it using this code: <?php session_start(cap.php); ?> <form method="post" name="captcha" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> <img src="cap.php" /> <input type="text" name="test" /> <input type="submit" name="submit" value="check" /> </form> <?php if (isset($_POST['submit']) && ($_SESSION['key'] =$_POST['test'])) { echo 'sent'; } elseif($_SESSION['key'] != $_POST['test']) { echo 'You entered the wrong code!'; } else { echo 'nothing happened'; } ?> I am a beginner with the CAPTCHA stuff so some help to get it working will be great. I know theirs something wrong with the sessions but I can't get it to work. Best Regards. Link to comment https://forums.phpfreaks.com/topic/98369-captcha-help/ Share on other sites More sharing options...
redarrow Posted March 28, 2008 Share Posted March 28, 2008 incorrect... <?php session_start(cap.php); ?> to <?php session_start(); include("cap.php"); ?> Link to comment https://forums.phpfreaks.com/topic/98369-captcha-help/#findComment-503398 Share on other sites More sharing options...
Imad Posted March 28, 2008 Author Share Posted March 28, 2008 incorrect... <?php session_start(cap.php); ?> to <?php session_start(); include("cap.php"); ?> Thanks for your reply. I previously tried it but it didn't work. The form disappeared and the Captcha was only parsed. Regards. Link to comment https://forums.phpfreaks.com/topic/98369-captcha-help/#findComment-503401 Share on other sites More sharing options...
BlueSkyIS Posted March 28, 2008 Share Posted March 28, 2008 regardless, redarrow is correct. this will get you nowhere fast: session_start(cap.php); Link to comment https://forums.phpfreaks.com/topic/98369-captcha-help/#findComment-503416 Share on other sites More sharing options...
Imad Posted March 28, 2008 Author Share Posted March 28, 2008 regardless, redarrow is correct. this will get you nowhere fast: session_start(cap.php); Of course it will. I knew it was incorrect but thought I'd give it a whirl anyway. I said it in my first post btw. Link to comment https://forums.phpfreaks.com/topic/98369-captcha-help/#findComment-503417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.