PHP script help for complete novice Please
Posted: Sat May 22, 2010 4:51 pm
Hi guys and gals...I wonder could somebody kindly help me out?
I make forum signatures for an online baby forum, like this:

I add the age ticker using a code somebody did for me and then upload it to my server....he made it pretty simple so I can understand how to change the font, colour, alignment etc.... but I am wanting to go a little further and add 2 different age tickers to one image...for example i make a signature with 2 little boys on, I want to put 2 tickers underneath relevant to each child..
can this be done?
This the script I am using:
Thank you in advance 
I make forum signatures for an online baby forum, like this:
I add the age ticker using a code somebody did for me and then upload it to my server....he made it pretty simple so I can understand how to change the font, colour, alignment etc.... but I am wanting to go a little further and add 2 different age tickers to one image...for example i make a signature with 2 little boys on, I want to put 2 tickers underneath relevant to each child..
can this be done?
This the script I am using:
Code: Select all
<?php
header('content-type: image/png');
// ---------- DO NOT EDIT ANYTHING ABOVE ----------
$image = "IMAGE NAME HERE.png";
$born_day = 17;
$born_month = 4;
$born_year = 2009;
$font = 'comic.ttf';
$fontsize = 12;
$slant = 0;
$margin_left = 55;
$margin_top = 250;
// ignore these, go down 17 lines to change the font colour
$image = imagecreatefrompng($image);
$red = ImageColorAllocate($image, 255, 0, 0);
$green = ImageColorAllocate($image, 0, 153, 0);
$blue = ImageColorAllocate($image, 0, 0, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$white = ImageColorAllocate($image, 255, 255, 255);
$yellow = ImageColorAllocate($image, 255, 255, 0);
$aqua = ImageColorAllocate($image, 0, 255, 255);
$fuschia = ImageColorAllocate($image, 255, 0, 255);
$grey = ImageColorAllocate($image, 153, 153, 153);
$silver = ImageColorAllocate($image, 204, 204, 204);
$teal = ImageColorAllocate($image, 0, 153, 153);
$lime = ImageColorAllocate($image, 0, 255, 0);
$navy = ImageColorAllocate($image, 0, 0, 153);
$purple = ImageColorAllocate($image, 153, 0, 153);
$maroon = ImageColorAllocate($image, 153, 0, 0);
$olive = ImageColorAllocate($image, 153, 153, 0);
// don't forget the font colour
$fontcolor = $red;
// ---------- DO NOT EDIT ANYTHING BELOW ----------
//gets the difference between today and $bornon
$today = mktime();
$bornon = mktime(0, 0, 0, $born_month, $born_day, $born_year);
$diff = ($today - $bornon);
// calculate days, months, years
$years = floor($diff/(60*60*24*365));
$months = floor( ($diff - ($years * (60*60*24*365)))/(60*60*24*(365/12)));
$days = floor(($diff - ($years * (60*60*24*365)) - ($months * (60*60*24*(365/12))))/(60*60*24));
// text to superimpose onto the image
$text = sprintf("CHILDS NAME OR ANY TEXT HERE is %s years, %s months and %s days old",$years, $months, $days);
// make image
imagettftext($image, $fontsize, $slant, $margin_left, $margin_top, $fontcolor, $font, $text);
// display image
imagepng($image);
// all done...
imagedestroy($image);
?>