lipun4u Posted October 26, 2009 Share Posted October 26, 2009 I have been trying to implement a captcha in php... here is the code.. <?php // Set the content-type header('Content-type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = 'Testing...'; // Replace path by your own font path $font = 'arial.ttf'; // Add some shadow to the text imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> But in the browser, it gives the following error... The image “http://127.0.0.1:9000/img1.php” cannot be displayed, because it contains errors. Somebody tell me the reason and how to fix this .. Quote Link to comment https://forums.phpfreaks.com/topic/178998-captcha-error/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.