The code below takes the name field entered in a HTML form and outputs " hello [entered name] how are you. Also in the form there is a selection for gender either male or female. I would like the CGI script to change background color to green color if chosen male and yellow color if chosen female. Right now the color is static(pink). I've been trying to get it to work but no luck
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
component parts
$qstring = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $qstring);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
&thank_you;
#}
sub thank_you {
print "Content-type: text/html\n\n";
print <<EndStart;
<html>
<body bgcolor="#ff69b4" value="F" >
<hr>
EndStart
print "<p>hello</p>\n"; print "<blockquote><em>$FORM{name} how are you </em></blockquote>\n\n";
print <<EndHTML;
</body>
</html>
EndHTML
exit(0);
Part of the HTML code
What is your gender? <input type="radio" name="gen1" value="M"> male <br>
<input type="radio" name="gen2" value="F"> female <br>
name: <input type="text" name="name"><br>