Since the internet is a stateless environment, you need some way of maintaining state.
The options I see for you are:
- Pass all answers through the whole app, using hidden fields.
- Drop a cookie with some sort of ID, and write the results to a text file/database. Then retrieve the data based on ID on the 3rd page.
I prefer the second option, but both should work for a relatively small application like this.
Also, a side note, instead of
my $who = param("firstname");
my $who2 = param("lastname");
my $email = param("email");
my $firstquestion = param("FirstQuestion");
my $secondquestion = param("SecondQuestion");
my $thirdquestion = param("ThirdQuestion");
my $fourthquestion = param("FourthQuestion");
my $fifthquestion = param("FifthQuestion");
my $answerfirstquestion = param("AnswerFirstQuestion");
my $answersecondquestion = param("AnswerSecondQuestion");
my $answerthirdquestion = param("AnswerThirdQuestion");
my $answerfourthquestion = param("AnswerFourthQuestion");
my $answerfifthquestion = param("AnswerFifthQuestion");
my $useranswerfirstquestion = param("UserAnswerFirstQuestion");
my $useranswersecondquestion = param("UserAnswerSecondQuestion");
my $useranswerthirdquestion = param("UserAnswerThirdQuestion");
my $useranswerfourthquestion = param("UserAnswerFourthQuestion");
my $useranswerfifthquestion = param("UserAnswerFifthQuestion");
my $choicesfirstquestion = param("ChoicesFirstQuestion");
my $choicessecondquestion = param("ChoicesSecondQuestion");
my $choicesthirdquestion = param("ChoicesThirdQuestion");
my $choicesfourthquestion = param("ChoicesFourthQuestion");
my $choicesfifthquestion = param("ChoicesFifthQuestion");
You could use
my %cgi_data = Vars(); #Vars() is imported from CGI.pm
I just think it looks a lot cleaner. It also would allow you to simplify your form output using a loop.