Page 1 of 1

need some help

Posted: Fri Feb 21, 2014 9:22 pm
by pentool12
i wanna put a textbox here and the input from textbox will be replace 'this is text'.

Code: Select all

<?php
$im = imagecreate(100, 30);
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 0, 0, 'this is text', $textcolor);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

Re: need some help

Posted: Fri Feb 21, 2014 10:33 pm
by pbs
this will be your form

Code: Select all

<form action="" method="post" name="frm">
	<input name="image_text" type="text" id="image_text" />
	<input name="btnSubmit" type="submit" />
</form>
so your php code will be

Code: Select all

<?php
if (isset($_POST['btnSubmit']))
{
     $im = imagecreate(100, 30);
     $bg = imagecolorallocate($im, 255, 255, 255);
     $textcolor = imagecolorallocate($im, 0, 0, 0);
     $txt = trim($_POST['image_text']);
     imagestring($im, 5, 0, 0, $txt, $textcolor);
     header('Content-type: image/png');
     imagepng($im);
     imagedestroy($im);
}
?>
hope this will help you

Re: need some help

Posted: Fri Feb 21, 2014 10:41 pm
by pentool12
it's not working sir. the img cant be load.

Re: need some help

Posted: Fri Feb 21, 2014 11:30 pm
by pbs
pentool12 wrote:it's not working sir. the img cant be load.
are you getting any error, its working for me

Re: need some help

Posted: Fri Feb 21, 2014 11:35 pm
by pentool12
when i submit that form, the img was crash.
i run this php file using xampp.

Re: need some help

Posted: Fri Feb 21, 2014 11:53 pm
by pbs
pentool12 wrote:when i submit that form, the img was crash.
i run this php file using xampp.
check if GD library is enabled, also enable error_reporting to all

Re: need some help

Posted: Sat Feb 22, 2014 12:05 am
by pentool12
sir may you do it for me? i will pm you my t/viewer id and pword

Re: need some help

Posted: Sat Feb 22, 2014 12:14 am
by pbs

Re: need some help

Posted: Sat Feb 22, 2014 12:19 am
by pentool12
thank you very much sir. it's working

my previous code is

Code: Select all

<html>
<head>
</head>
<body>
<?php
if (isset($_POST['btnSubmit']))
{
     $im = imagecreate(100, 30);
     $bg = imagecolorallocate($im, 255, 255, 255);
     $textcolor = imagecolorallocate($im, 0, 0, 0);
     $txt = trim($_POST['image_text']);
     imagestring($im, 5, 0, 0, $txt, $textcolor);
     header('Content-type: image/png');
     imagepng($im);
     imagedestroy($im);
}
?>
<form action="" method="post" name="frm">
        <input name="image_text" type="text" id="image_text" />
        <input name="btnSubmit" type="submit" />
</form>
</body>
</html>
what error i have here?

Re: need some help

Posted: Sat Feb 22, 2014 12:23 am
by pbs
take the php code at the top or use this code

Code: Select all

<?php
if (isset($_POST['btnSubmit']))
{
     $im = imagecreate(100, 30);
     $bg = imagecolorallocate($im, 255, 255, 255);
     $textcolor = imagecolorallocate($im, 0, 0, 0);
     $txt = trim($_POST['image_text']);
     imagestring($im, 5, 0, 0, $txt, $textcolor);
     header('Content-type: image/png');
     imagepng($im);
     imagedestroy($im);
}
?>
<html>
<head>
</head>
<body>
<form action="" method="post" name="frm">
        <input name="image_text" type="text" id="image_text" />
        <input name="btnSubmit" type="submit" />
</form>
</body>
</html>

Re: need some help

Posted: Sat Feb 22, 2014 1:17 am
by pentool12
oh. i got it. thank you sir.