I'll post the code for both the form and the script below. If anyone spots the error, please do let me know.
aa.pl
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI::Carp qw{fatalsToBrowser};
use CGI;
use GD;
my $q = new CGI;
my $text = $q->param("text");
my $c1 = $q->param("c1");
my $c2 = $q->param("c2");
my $c3 = $q->param("c3");
my $img = GD::Image->new(400,90);
my $white = $img->colorAllocate(255,255,255);
my $color = $img->colorAllocate($c1,$c2,$c3);
my $font = "/home/username/Fonts/Verdana.ttf";
$img->stringFT($color, $font, 24, 0, 5, 80, $text);
print $img->png;
html form
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<form method="post" action="/a/aa.pl">
<table cellpadding="4" cellspacing="2" border="1">
<tr>
<td>Text: </td>
<td><input type="text" name="text" size="4"></td>
</tr>
<tr>
<td>Color: </td>
<td>R: <input type="text" name="c1" size="1"> G: <input type="text" name="c2" size="1"> B: <input type="text" name="c3" size="1"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value=" Go "></td>
</tr>
</table>
</form>
</BODY>
</HTML>