Page 1 of 1

Creating images with GD and PHP

New postPosted: Thu Mar 27, 2008 10:33 pm
by Ranman
# First create a file that will build the image calling it submit.php

<?
if ($str == "Submit!") { $width = 68; $heigth = 20; }
else { $width = 86; $heigth = 20; }
Header("Content-type: image/gif");
$image = ImageCreate($width,$heigth);
$light_blue = ImageColorAllocate($image,0,153,255);
$dark_blue = ImageColorAllocate($image,0,0,255);
imagestring($image,5,4,2,$str,$dark_blue);
ImageGif($image);
ImageDestroy($image);
?>


# Next create a test page calling it test.html

<?
if (!isset($set)) { $str = "Submit!"; }
else { $str = "Continue!"; }
$no_cashe = date("hi");
?>
<FORM ACTION="<? echo $PHP_SELF; ?>">
<INPUT TYPE="hidden" NAME="set" VALUE="1">
<CENTER>
<INPUT TYPE="image"
SRC="submit.php?str=<? echo $str; ?>&<? echo $no_cashe; ?>"
ALT="<? echo $str; ?>">
</CENTER>
</FORM>


# Lastly point your web browser at http://www.your.domain.com/test.html


Demo!--->http://www.linuxguruz.org/tutorials/38Demo.php