December 22, 20196 yr Hello friends, I am new to php and was following a youtube tutorial to create captcha but the code doesn't generate random number as i see in the tutorial here is the code index.php <?php //ini_set('display_errors','1'); //error_reporting(E_ALL); session_start(); $_SESSION["secure"] =rand(1000,9999); ?> <img src="generate.php"/> and the code for generate.php <?php session_start(); header("Content-type: image/jpeg"); $text =$_SESSION["secure"]; $font_size =30; $image_width =200; $image_height =40; $image = imagecreate($image_width,$image_height); imagecolorallocate($image,255,255,255); $text_color = imagecolorallocate($image,0,0,0); imagettftext($image,$font_size,0,15,30,$text_color,"font.ttf",$text); imagejpeg($image); ?> i have attached the font.ttf file font.ttf but when i run index.php all i see is blank page i checked php error log on wamp server it says the error on this line Quote imagettftext($image,$font_size,0,15,30,$text_color,"font.ttf",$text); but not sure how to fix any help will be highly appreciated Edited December 23, 20196 yr by sash_oo7 replaced font.ttf file
December 23, 20196 yr Author 5 hours ago, davep said: why is your font named font.ttf.ttf? i.e. a double extension? I replaced it with font.ttf but still same result..blank page
December 23, 20196 yr Lots of useful advice here along with working examples: https://www.php.net/manual/en/function.imagettftext.php I suspect the error is your font path
Create an account or sign in to comment