passing perl variable to output html file

A

andy.t.chou

I need to be able to have a hidden field (signiture) with each output
html file generated.


# (Get the first and last name from the html form)
$first_name = $q->param('FirstN');
$last_name = $q->param('LastN');


# attempting to pass the variable information to an output html file

to be used as hidden info needed to use later.


print HISTORY ('<INPUT TYPE="hidden" name="TestFirstN"
value="$first_name"\>');


print HISTORY ('<INPUT TYPE="hidden" name="TestLastN"
value="$last_name"\>');


When my second cgi script calls on the output html file from above..


my $fir = $q->param('TestFirstN');
my $la = $q->param('TestLastN');
print "$fir";
print "$la";


the debug print statements print out $first_name and $last_name instead

of the values that they are suppose to have. Can someone please help
me with this or provide another solution to basically be able to pass
variable from perl/cgi script to output html file. Thanks.
 
B

Brian McCauley

Gregory said:
Hint: What is the difference between '' and "" ?

Second hint: Since the HTML contains " characters see also the qq
quoting operator.

Third hint: If $last_name could ever contain the characters '"' or '&'
or then it needs escaping with something like CGI->escapeHTML(). ( It's
probably also wise although not strictly necessary if it could ever
contain '<' or '>').
 
S

Sherm Pendley

Gregory said:
Hint: What is the difference between '' and "" ?

Meta-hint: Have a look in "perldoc perlop" to find out, in the "Quote and
Quote-like Operators" section.

sherm--
 
G

Greg Schmidt

I need to be able to have a hidden field (signiture) with each output
html file generated.

# (Get the first and last name from the html form)
$first_name = $q->param('FirstN');
$last_name = $q->param('LastN');

# attempting to pass the variable information to an output html file

to be used as hidden info needed to use later.

print HISTORY ('<INPUT TYPE="hidden" name="TestFirstN"
value="$first_name"\>');

print HISTORY ('<INPUT TYPE="hidden" name="TestLastN"
value="$last_name"\>');

When my second cgi script calls on the output html file from above..

my $fir = $q->param('TestFirstN');
my $la = $q->param('TestLastN');
print "$fir";
print "$la";

the debug print statements print out $first_name and $last_name instead

of the values that they are suppose to have. Can someone please help
me with this or provide another solution to basically be able to pass
variable from perl/cgi script to output html file. Thanks.

What others have said is certainly all good to know, but in this
particular situation, since you're already using CGI.pm, you might look
up the "hidden" function in that module. I don't know whether you'd
need to use escapeHTML in conjunction with it; I suspect it would
automatically handle such details internally.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top