Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Simple Quiz Maker (cont.)

by tcf22 (Priest)
on Dec 06, 2003 at 02:05 UTC ( #312706=note: print w/replies, xml ) Need Help??


in reply to Simple Quiz Maker (cont.)

Since the internet is a stateless environment, you need some way of maintaining state.

The options I see for you are:
  1. Pass all answers through the whole app, using hidden fields.
  2. 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.

- Tom

Replies are listed 'Best First'.
Re: Re: Simple Quiz Maker (cont.)
by matthewb (Curate) on Dec 06, 2003 at 04:36 UTC
    #Vars() is imported from CGI.pm
    Not by default, it isn't. If you want to use the procedural interface to CGI.pm you'll have to make sure the :cgi-lib functions are imported first in order to use Vars() as a function.
    </pedantic_mode>
    MB

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://312706]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2020-10-30 22:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (286 votes). Check out past polls.

    Notices?