Hi Monks!

My perl code here should get some parameters from my html template, but I can't figure it out why I can't get the parameters sent back from the HTML to print after a click on the button(s) on the form. I can see the parameters been passed, by the perl ignores it.
Can someone help on that? Or explain why this is happening?

The Perl code
#!/perl/bin/perl use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use DBI; my $q = new CGI; print header(); #print "Test"; my $userip = $ENV{'REMOTE_ADDR'}; #print $userip; my $curr_dir; #print $userip; # Grab the current directory from $0. BEGIN { $0 =~ '(.*[\\\/])\w+\.\w+$'; $curr_dir = $1 || "./"; } my $display = &filter($q->param('display')) || ''; my $insert = &filter($q->param('insert')) || ''; my $confir = &filter($q->param('confir')) || ''; my %AoH; if($insert eq "insert"){ $AoH{MESS} = "OK your message has been received!"; }else{ $AoH{MESS} =""; } print "<br><b>I must to print these values here once the buttons on th +e form has been clicked:</b><br>***INSERT=$insert******DISPLAY=$displ +ay******CONFIR=$confir######<br>"; my $out_file; $out_file = "${curr_dir}table.html"; open(OUTPUT, "$out_file") || print "L40 - There is no file here, I'll +run away now!"; while(<OUTPUT>) { $_=~s/<!-- (\bMESS\b)\/\/ -->/$AoH{MESS}/g; print $_; } close OUTPUT; ####################################### ### Filter - Gets rid of characters that screw up the program. sub filter { if($_[0]){ $_[0]=~s/\s+$//; $_[0]=~s/\'/\\\'/g; $_[0]=~s/<//g; $_[0]=~s/>//g; $_[0]=~s/;//g; $_[0]=~s/\(//g; $_[0]=~s/\)//g; $_[0]=~s/\"//g; $_[0]=~s/\'//g; $_[0]=~s/\?//g; $_[0]=~s/\<script//g; #$_[0]=~s/\///g; $_[0]=~s/>//g; #$_[0]=~s/\%2F//g; return $_[0]; }else{ return ''; } } ### End Filter Sub


The HTML template code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3 +.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Test</title> </head> <body> Test<br> <form name="upf" method="post"> <input type="hidden" name="update" value="update"> <input type="submit" name="upf" value="Cancel" onClick="docum +ent.upf.action='test.pl';"> <br><br> <input type="submit" name="upf" value="Insert" onClick="docum +ent.upf.action='test.pl?insert=insert';"> <br><br> <input type="submit" name="upf" value="Confirm" onClick="docu +ment.upf.action='test.pl?confir=confir';"> </form> <!-- MESS// --> </body> </html>


Thanks a lot for the help!

In reply to Passing Parameters Help! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.