Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Unwanted CGI "Submit" Parameter

by Anonymous Monk
on Oct 06, 2000 at 16:33 UTC ( [id://35565]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using the post method to send form data to a perl script (I am using cgi_lib to get the parameters). The URL that is then created looks something like this: foo.pl?parameter=value&submit=Submit Why is the submit button being parsed as a parameter? Is there a way I can remove this?

Replies are listed 'Best First'.
(ar0n) RE: Unwanted CGI
by ar0n (Priest) on Oct 06, 2000 at 16:52 UTC
    Because the submit button is a form-element just like any other, and sometimes you'd like to do something depending on what value the submit button is set to.

    It would be alot easier for us to help you if you'd care to explain why you don't want the submit parameter...

    [ar0n]

      Hmmm... that's not entirely true. There's a big difference in these two submit buttons:
      <input type=Submit value="This doesn't have a value"> <input type=Submit name=Submit value="This one has a value">
      In other words, if you don't provide a name, there is nothing to associate the value to. Am I missing out on something important or has everyone gone gaga? :) Also, on a side note, I'd drop cgi-lib.pl and start using CGI.pm with the compatibility mode. Ie:
      use CGI; CGI::ReadParse(*in);
      My R$0.02 (its less than two cents when you convert it to US$)

      #!/home/bbq/bin/perl
      # Trust no1!
        You are totally correct.. In my experience I generally don't see a submit input item with a name attribute unless the coder is interested in the value of the submit button..
        <input type='submit' name='submit' value='Next'> <input type='submit' name='submit' value='Previous'>
        Of course you can make it whatever name you want, but if you don't particularly care what submit button they hit, just don't provide a name attribute:
        <input type='submit' value='Save'>
Re: Unwanted CGI
by kilinrax (Deacon) on Oct 06, 2000 at 16:59 UTC
    You could quite easily get a list of all the parameters except 'submit' thusly:
    #!/usr/bin/perl -w use strict; use CGI; my $query = new CGI; my @params = grep {$_ ne 'submit'} $query->param;
      Why not use the CGI API?
      #!/usr/bin/perl -w use strict; use CGI; my $query = new CGI; my $query->delete('submit');
Re: Unwanted CGI
by Anonymous Monk on Oct 07, 2000 at 04:52 UTC
    Thanks for the help! I was giving the submit button a name when I shouldn't have been. Basically, the only reason I didn't want this is because it is annoying. Also, I'll take everyones advice and start using cgi.pm

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://35565]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-25 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found