in reply to perl CGI: updating hidden field values for self-referring url
tangent already solved it for you. Here's a recap with some style changes and security amendments.
use strict; use warnings; # Uninitialized errors are normal for this kind of CGI. no warnings "uninitialized"; # LWP was not being used. use CGI; # Do not leave this in the script production. use CGI::Carp qw(fatalsToBrowser); # ->new is better; search indirect object syntax problems. my $q = CGI->new; print $q->header, $q->start_html; my $previousTotal = $q->param('sumTotal'); # Printing raw user input is a serious security problem. # Adding 0 will numify and clobber strings like "<script />" print $q->h2("Previous Total:", $previousTotal + 0); my $currentTotal = $previousTotal + 2; # Don't need "print" for every op and please do not put "br"s # everywhere for formatting. print $q->h2("Current Total:", $currentTotal), $q->start_form( -name => 'addition', -method => 'GET' ), $q->hidden( -name => 'sumTotal', -override => 1, -value => $currentTotal ), $q->submit( -name => 'button', -value => 'Add 2' ), $q->end_form, $q->end_html; exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl CGI: updating hidden field values for self-referring url
by choroba (Cardinal) on Feb 17, 2014 at 19:54 UTC | |
by Your Mother (Archbishop) on Feb 17, 2014 at 20:13 UTC | |
by Anonymous Monk on Feb 18, 2014 at 00:44 UTC |