So what I'm trying to do here is to build a couple for webpages. So there is main page(say m1). so m1 has just a input field and a submit button. So what I want to do is get the variable (a string) from the input field in main page and then compare it with a set of strings and then redirect to the corresponding webpage. For example, if I enter "blue" in input field, it should take the value, compare it with set of values and redirect to corresponding webpage(maybe a page with blue background)
Here is the code I'm trying with, which I got after a long search.
use CGI qw/:standard :html3/;
# this defines the contents of the fill out forms
# on each page.
@PAGES = ('Main','Blue','Red','Yellow','Green');
%FIELDS = ('Main' => ['Name'],
);
# accumulate the field names into %ALL_FIELDS;
foreach (values %FIELDS) {
grep($ALL_FIELDS{$_}++,@$_);
}
# figure out what page we're on and where we're heading.
$current_page = calculate_page(param('page'),param('go'));
$page_name = $PAGES[$current_page];
print_header();
print_form($current_page) if $FIELDS{$page_name};
print_review($current_page) if $page_name eq 'Review';
print_confirmation($current_page) if $page_name eq 'Confirmation';
print end_html;
# CALCULATE THE CURRENT PAGE
sub calculate_page {
my ($prev,$dir) = @_;
return 0 if $prev eq ''; # start with first page
return $prev + 1 if $dir eq 'Submit Application';
return $prev + 1 if $dir eq 'Next Page';
return $prev - 1 if $dir eq 'Previous Page';
}
# PRINT HTTP AND HTML HEADERS
sub print_header {
print header,
start_html("Your Friendly Family Loan Center"),
h1("Your Friendly Family Loan Center"),
h2($page_name);
}
# PRINT ONE OF THE QUESTIONNAIRE PAGES
sub print_form {
my $current_page = shift;
print "Please enter the name",
start_form,
hr;
draw_form(@{$FIELDS{$page_name}});
print hr;
print submit(-name=>'go',-value=>'Previous Page')
if $current_page > 0;
print submit(-name=>'go',-value=>'Submit'),
hidden(-name=>'page',-value=>$current_page,-override=>1),
end_form;
}
My Question is how do I access the variable that is Submitted in first page and how to compare with the set of variables ? when I say set of variables it means a array which has values red blue green yellow