adrive has asked for the wisdom of the Perl Monks concerning the following question:
process.pl :#!/usr/bin/perl print "content-type: text/html \n\n"; use strict; use warnings; use CGI; use CGI::Session qw/-ip-match/; my $cgi = new CGI; my $session; if($cgi->param("failed")){ $session = CGI::Session->load($cgi->param("sessionid")); $session->load_param($cgi); }else{ $session = new CGI::Session(); } my $sessionid = $session->id(); print<<output; <html> <body> previously selected : output my @keywords = $cgi->param("person"); foreach my $x(@keywords){ print "($x)\n"; } print<<output; <form action="process.pl" method="post"> <INPUT TYPE="hidden" NAME="sessionid" VALUE="$sessionid"/> <input type="checkbox" name="person" value="1"/>Alex <input type="checkbox" name="person" value="2"/>Robin Hood <input type="checkbox" name="person" value="3"/>Batman <input type="submit"/> </form> </body> </html> output
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Session qw/-ip-match/; # instantiate a new CGI object my $cgi = new CGI; my $sessionid = $cgi->param("sessionid"); my $proceedFlag = 0; my $session = CGI::Session->load($sessionid); open(LOGFILE, ">>log.txt"); print LOGFILE "gonna save cgi person as : ". $cgi->param("person") +."\n"; close LOGFILE; $session->save_param($cgi); if($proceedFlag){ print $cgi->redirect( -URL => 'test2.pl?sessionid='.$sessi +onid); }else{ # return to previous page with its session print $cgi->redirect( -URL => 'test1.pl?sessionid='.$sessi +onid."&failed=1"); }
|
|---|