CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [FishMonger] cgi.pm question: difference between param and cookie: Edit Log



ningji
Novice

Nov 2, 2012, 2:47 PM


Views: 2235
Re: [FishMonger] cgi.pm question: difference between param and cookie

Hi FishMonger,

sorry my copy paste screwed up.
anyway here it is again.
The problem is webpage only displays 1 and 2, no matter how many clicks you do. (i was expecting 1 1, then 1 2, then 2 3 ...)

#!/usr/bin/perl -w

BEGIN { push @INC, "/usr/share/perl5"; }
BEGIN { push @INC, "/usr/share/perl5/CGI"; }

use strict;
use warnings;
use CGI;
use CGI qw(:standard);

my $q = new CGI;

my $v1 = $q->param("first_var");
my $v2 = $q->param("second_var");
my $v3=0;
my $opt = $q->param("rsubmit");

############################
if($opt eq "Next page")
{
$v3 = $v1 + $v2;
$v1 = $v2;
$v2 = $v3;

$q->param(-name=>"first_var", -value => $v1);
$q->param(-name=>"second_var", -value => $v2);
}

############################
print $q->header();
print $q->start_html( );

print $q->h4($v1);
print $q->h4($v2);
print $q->h4($opt);

print $q->start_form(
-name => 'main',
-method => 'POST',
);

print $q->hidden(-name=>"first_var", -default=>1, -override=>1);
print $q->hidden(-name=>"second_var", -default=>1, -override=>1);
print $q->submit(-name=>'rsubmit', -value => 'Prev page');
print $q->submit(-name=>'rsubmit', -value => 'Next page');

print $q->end_form;
print $q->end_html;

exit 0;


(This post was edited by ningji on Nov 2, 2012, 2:49 PM)


Edit Log:
Post edited by ningji (Novice) on Nov 2, 2012, 2:49 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives