<?php
$button_text = $_POST['button_text'];
$color = $_POST['color'];
if (empty($button_text) || empty($color))
{
    echo 'Could not create image - form not filled out correctly';
    exit;
}
// create an image of the right background and check size
$im = imagecreatefrompng ($color.'-button.png');
$white = ImageColorAllocate ($im, 255, 255, 255);
imageitring($im, 44, 60, 28,  $button_text, $white);
header ('Content-type: image/png');
imagepng ($im);
imagedestroy ($im);
?>