/ Published in: PHP
Save this snippet as .php file and use it as image source.
This captcha code shows random arithmetic's questions.
You can download needed font from http://www.1001fonts.com/font_details.html?font_id=2939
This captcha code shows random arithmetic's questions.
You can download needed font from http://www.1001fonts.com/font_details.html?font_id=2939
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$width = 120; $height = 30; for( $i=0; $i<($width*$height)/3; $i++ ) { } /* generate random lines in background */ for( $i=0; $i<($width*$height)/120; $i++ ) { } if($action[0] == '+') { $_SESSION['code'] = $a + $b; } elseif($action[0] == '*') { $_SESSION['code'] = $a * $b; } elseif($action[0] == '-') { $c = $b+1; $_SESSION['code'] = $a - $b; } $text = $a.$action[0].$b; imagettftext($im, 18, $angle, 29+($j*23), (18+(($height-18)/2)), $text_color, './WC_Wunderbach_Rough.ttf', $text[$j] ); } //usage : save this snippet as captcha.php file and use it that //point it as image source //<img src="captcha.php" /> //to check is it passed correctly, do following //if(isset($_SESSION['code']) && ($_POST['captcha'] == $_SESSION['code'])) //its needed to check is $_SESSION['code'] is set, because if somebody block //the image loading, the check ($_POST['captcha'] == $_SESSION['code']) will //return false positive if the form is sent with empty captcha field