Cagecrawler Posted January 16, 2007 Share Posted January 16, 2007 I'm trying to create an image to use for registration to stop bots. I've managed to create the image, but when I try to insert anything into the file, or insert it into another file, I get the following error:[code]The image “register.php” cannot be displayed, because it contains errors.[/code]In this case, the image code is in key.php, and the file I'm trying to insert it into is called register.php.Can anybody help please? Link to comment https://forums.phpfreaks.com/topic/34358-creating-images-using-php/ Share on other sites More sharing options...
Cagecrawler Posted January 16, 2007 Author Share Posted January 16, 2007 Here's key.php:[code]<?phpfunction genText($length) {$p_chars=md5(time()); // can be any set of characterswhile(strlen($out_str)< $length){$out_str.= $p_chars{rand()%(strlen($p_chars))};}return $out_str;}$rand_string = genText(8);header ("Content-type: image/png");$im = imagecreate(60, 20);$bg = imagecolorallocate($im, 0, 255, 255);$text_color = imagecolorallocate($im, 0, 0, 255);imagestring($im, 2, 5, 3,$rand_string, $text_color);imagepng($im);imagedestroy($im);?>[/code] Link to comment https://forums.phpfreaks.com/topic/34358-creating-images-using-php/#findComment-161713 Share on other sites More sharing options...
Cagecrawler Posted January 16, 2007 Author Share Posted January 16, 2007 Solved... I wasn't using <img src="key.php"> Link to comment https://forums.phpfreaks.com/topic/34358-creating-images-using-php/#findComment-161744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.