I want to make ID card for members that registered on my web. After user register they can click print and ID card generated (png or jpg). I use PHP function imagettftext but it's not working. I don't know where is wrong code. My code:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/ektp/header.php');//Database config and session login
$id = $_GET['id'];
$sql = "SELECT * FROM data WHERE noktp=$id";
$result = $conn->query($sql);
$row = $result->fetch_array();
$noid = $row['id'];
$name = $row['name'];
$addr = $row['address'];
$im = imagecreatefrompng('./ektp.png');
$black = imagecolorallocate($im, 0, 0, 0);
$font = "./Ubuntu-R.ttf";
imagettftext($im, 15, 0, 200, 35, $black, $font, $noid);
imagettftext($im, 15, 0, 200, 65, $black, $font, $name);
imagettftext($im, 15, 0, 200, 85, $black, $font, $addr);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
Solved by self, my problem is
include($_SERVER['DOCUMENT_ROOT'].'/ektp/header.php');
Work for several file but not working with imagettftext, so I change to
include('../header.php')
and I have some html elements in header.php like
<style>
<script>
so I split to another file. In header.php just database config and..
Image displayed with text from database :)