passing perl variable to output html file

Discussion in 'Perl Misc' started by andy.t.chou@gmail.com, Mar 26, 2005.

  1. Guest

    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.
     
    , Mar 26, 2005
    #1
    1. Advertising

  2. wrote:

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


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

    gtoomey
     
    Gregory Toomey, Mar 26, 2005
    #2
    1. Advertising

  3. Gregory Toomey wrote:

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

    >
    >
    > 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 '>').
     
    Brian McCauley, Mar 26, 2005
    #3
  4. Gregory Toomey wrote:

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

    >
    > 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--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Mar 26, 2005
    #4
  5. Greg Schmidt Guest

    On 26 Mar 2005 00:14:20 -0800, wrote:

    > 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.

    --
    Greg Schmidt
    Trawna Publications http://www.trawna.com/
     
    Greg Schmidt, Mar 26, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    2,722
    Joe Smith
    Mar 27, 2005
  2. shil
    Replies:
    2
    Views:
    2,035
    Eliyahu Goldin
    Jan 2, 2007
  3. pereges
    Replies:
    7
    Views:
    439
    pereges
    Jun 1, 2008
  4. Jonas Daunoravicius
    Replies:
    5
    Views:
    315
    Peter
    Jul 17, 2003
  5. Replies:
    3
    Views:
    246
Loading...

Share This Page