hello friends, please tel me how to generate php code of image code generation. In need it urgently. thanks
i think you are talking about captcha images.you can use lots of open source scripts from internet.just give a search and you will get a lot of links for image validation using captcha
Here is a code i used long ago to create captcha image <?php function random_color($im, $min, $max) { return imagecolorallocate($im, mt_rand($min, $max), mt_rand($min, $max), mt_rand($min, $max)); } function random_ellipse($im, $min_x, $max_x, $min_y, $max_y, $w, $h) { $col = random_color($im, 220, 250); $x = mt_rand($min_x, $max_x); $y = mt_rand($min_y, $max_y); imageellipse($im, $x, $y, $w, $h, $col); imageellipse($im, $x+1, $y+1, $w, $h, $col); } $im_width = 160; $im_height = 40; $font = 'font.ttf'; $font_size = 12; $im = imagecreate($im_width, $im_height); imagecolorallocate($im, 252, 252, 252); random_ellipse($im, 5, 20, 5, 20, 110, 30); random_ellipse($im, 100, 120, 5, 20, 110, 40); random_ellipse($im, 80, 100, 30, 50, 140, 50); $chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZ'; $max = strlen($chars) - 1; $num = ""; for($i=0; $i<5; $i++) { $char = $chars{mt_rand(0, $max)}; $rotation = ($i % 2) ? -6 : 6; imagettftext($im, $font_size, $rotation, $i * 26 + 20, 26,random_color($im, 50, 240), $font, $char); $num .= $char; } $black = imagecolorallocate($im, 0, 0, 0); imagerectangle($im, 0, 0, $im_width-1, $im_height-1, $black); setcookie("num", md5($num), time()+600); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> Code (php): Of course you'll need to upload a font file and replace font.tff with it. And for verification if (md5(strtoupper($_POST['vimg'])) != $_COOKIE['num']){echo "Invalid Image Verification Code";} Code (php): Edit: It uses cookies. I could create you one to use sessions.
Try with GD library function. Or you can search at hotscripts.com for image verification script for free. thanx