hi,
############
FORM PROGRAM
############
#!c:/perl/bin/perl
use CGI ':standard';
print header;
@menu = ('USA', 'China', 'Canada', 'Mexico' );
print '<FORM
ACTION="
http://localhost/cgi-bin/fig-5-4-prog.cgi"
METHOD="POST">';
print '<FONT SIZE=4 > What countries have you visited?';
print br;
print '<INPUT TYPE="checkbox" NAME="places" VALUE="0"checked>', "$menu[0]";
print br;
print '<INPUT TYPE="checkbox" NAME="places" VALUE="1">', "$menu[1]";
print br;
print '<INPUT TYPE="checkbox" NAME="places" VALUE="2"checked>', "$menu[2]";
print br;
print '<INPUT TYPE="checkbox" NAME="places" VALUE="3"checked>', "$menu[3]";
print br;
print br, '<INPUT TYPE=SUBMIT VALUE="Submit">';
print '<INPUT TYPE=RESET></FORM>', end_html;
##############
RECEIVING PROGRAM
##############
#!c:/perl/bin/perl
use CGI ':standard';
print header, start_html("Got Your Countries");
@menu = ('USA', 'China', 'Canada', 'Mexico' );
@response =param('places');
if (@response =~ /[023]/)
{
print "You have travelled to: <b>@menu[@response]</b><br
>";
print "Why not try travelling to <b>Asia?</b>";
}
elsif (@response =~ /[1]/)
{
print "You have travelled to: <b>@menu[@response]</b><br
>";
print "Why not try travelling to <b>North America<b>";
}
elsif (@response =~ /[0123]/)#Blank screen
{
print "You have travelled to: <b>@menu[@response]</b><br
>";
print "It would be recomended that you become a <b>frequent flyer<b> with the company";
}
elsif (@response =~ /[0]/)
{
print "You have travelled to: <b>@menu[@response]</b><br
>";
print "You have not travelled to <b>Canada, Mexico or Asia<b>";
}
elsif (@response =~ /[2]/)
{
print "You have travelled to: <b>@menu[@response]</b><br
>";
print "You have not travelled to <b>US, Mexico or Asia<b>";
}
elsif (@response =~ /[3]/)
{
print "You have travelled to: <b>@menu[@response]</b><br
>";
print "You have not travelled to <b>US, Canada, or Asia<b>";
}
print "</FONT>", end_html;
The problem is that it does not match my IF's exclusively.
EG. If i just select 0 - North America
it should say you have travveled to us but u have not travelled to canada, mexico or asia
if u run my program u will see the problem as it is hard to explain.
thanks
pete
ASKER
in mine the wrong answers r output,
the places variable passes through the correct value from the form and it is entered in respose variable.
then it should be a simple case of pattern matching variable response to see what msg to output.
ie. if response says 023, then output why not travel to asia.
i do not understand why my program is picking the wrong statement,
thanks pete