I am creating image using php i almost code it but i stucked at a very important point I want the Font family of my choice in that image but only when i select the font family otherwise the default font runs. This logic is not running properly. When i didn't choose any font family the default font runs and shows me the input but when i choose any font then it also runs and existing image overwrite but it is not showing me the input on screen.
Please tell me what is the issue. Here is my code of php file:
<?php
include_once('includes/includes.inc.php');
if(isset($_GET['txt'])){
$txt = $_GET['txt'];
$_SESSION['txt'] = $txt;
}
if(!isset($_SESSION['rand'])){
$rand = mt_rand(100,1000);
$_SESSION['rand'] = $rand;
}
$im = @imagecreate(288, 288) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 230, 248, 248);
$text_color = imagecolorallocate($im, 85, 85, 85);
if(isset($_GET['Smile'])){
$query = mysql_query("SELECT * FROm tbl_fonts WHERE font_name = '".$_GET['Smile']."'");
$get = mysql_fetch_array($query);
$desfon = 'images/fonts/'.$get['font_name'].'.ttf';
//echo $desfon;
imagettftext($im, 55, 0, 155, 55, $text_color, $desfon, $_SESSION['txt']);
}
else{
imagestring($im, 55, 155, 55, $_SESSION['txt'], $text_color);
}
header("Content-Type: image/png");
$filename1 = $_SESSION['txt'].$_SESSION['rand'].'.png';
imagepng($im,$filename);
echo '<img src="'.$filename.'" alt="" />';
?>