[ back to toc ]

returning images with a cgi script

Date: 2002/03/27 21:10

Q:
I am trying to create a page that returns the capital, number (of when it
joined the union)and an image of the state flag. I have been able to
return all but the image. I have tried using the same parsing statement
that returns the other information and when that didn't work I tried an
if/elsif statement. I can get all of the images to display on each of the
pages if I comment out the if/else statements. I am using xitami
#!usr/bin/perl
print"Content-type: text/html\n\n";
use CGI qw(:standard);
print"<html>\n";
print"<head><title>Stark State College of Technology</title></head>\n";
print"<body bgcolor=ffe7c6><basefontsize=5>\n";

print"<center>The capital of ", param('state')," is ",
param('cap'),".<br> It was the ",param('num')," state to join the
union.<br><br>\n";
print"<br><br> This is its flag.<br><br> ", param('flag'),"\n";

# if ({'state'} eq "Ohio"){
# print"<img src=\"images/ohioflag.gif\">\n";
# }
# elsif ({'state'} eq" Kentucky"){
# print"<img src=\"images/kentuckflag.gif\">\n";
# }
# elsif ({'state'} eq "Wyoming"){
# print"<img src=\"images/wyomflag.gif\">\n";
# }
# elsif ({'state'} eq "California"){
# print"<img src=\"images/califflag.gif\">\n";
# }
print"</center></body></html>\n";
End of script

<html>
<head>
<title>Stark State College of Technology</title>
</head>
<body bgcolor=FFE7C6><basefont size=5>
<center>
<img src="images/ssct.gif"><br><br>
<h2>Click a state name</h2><br><br>
<a
href="http://localhost/cgi-bin/glenda.cgi?state=Ohio&cap=Columbus&num=seve
nteenth&img src=../images/ohioflag.gif">Ohio</a>

<a
href="http://localhost/cgi-bin/glenda.cgi?state=Kentucky&cap=Frankfort&num
=fifteenth&img src=../images/kentuckflag.gif">Kentucky</a>

<a
href="http://localhost/cgi-bin/glenda.cgi?state=Wyoming&cap=Cheyenne&num=f
orty fourth&img src=../images/wyomflag.gif">Wyoming</a>
<a
href="http://localhost/cgi-bin/glenda.cgi?state=Colorado&cap=Denver&num=th
irty eighth&img src=../image/colorflag.gif">Colorado</a>

<a
href="http://localhost/cgi-bin/glenda.cgi?state=California&cap=Sacramento&
num=thirty first&img src=../images/califflag.gif">California</a>
</center>
</body>
</html>

A:
if ({'state'} eq "Ohio"){

rather you mean:

if (param('state') eq "Ohio"){

[ back to toc ]