Forum Moderators: open

Message Too Old, No Replies

form get/post method

why will get work and not post?

         

molecularr

11:16 pm on Apr 2, 2004 (gmt 0)

10+ Year Member



Hi everyone,

Long time reader, first time poster...

Got a little problem with processing a form (it's through a standard perl/cgi script. Originally from the O'reilly Mouse book I think).

The processing sub seems to work fine for both post and get method in isolated tests, but when I actually try to use it in a page, the "post" method fails to produce any results when "get" works fine.

I suspect this has something to do with some differences between "post" and "get" that I'm not aware of. I have a form that I need to use for uploading a fairly large amount of text, so the "get" exceeds the URL limit.

Anyone have any insights to share? Thanks.
-M

VectorJ

4:42 am on Apr 3, 2004 (gmt 0)

10+ Year Member



POST and GET are read very differently in Perl.


if ($ENV{'QUERY_STRING'}) {
$query = $ENV{'QUERY_STRING'};
} elsif ($ENV{'CONTENT_LENGTH'} > 0) {
read(STDIN,$query,$ENV{'CONTENT_LENGTH'});
} else {
return(0);
}

In both of the cases above (the first is GET the second is POST) the result ends up in $query.

Hope this helps. If not, a bit more info about the problem might help....

molecularr

4:12 pm on Apr 3, 2004 (gmt 0)

10+ Year Member



Vector -

My Perl looks a lot like your example, and it seems to work fine in "isolated" tests I set up. Here's my code for the form that's giving me problems:

<form action="check.cgi" enctype="text/plain" METHOD="POST">
<textarea rows=14 cols=40 name="comment"></textarea>

<p>What is your recommendation for this submission?</p>
<input type="radio" name="recommend" value="approve1">Accept with minimal revisions.<br>
<input type="radio" name="recommend" value="approve2">Accept with revisions (please specify above).<br>

<input type="radio" name="recommend" value="approve3">Accept with major revisions (please specify above).<br>
<input type="radio" name="recommend" value="approve4">Reject.
<input type="hidden" name="ID" value="">
<input type="hidden" name="name" value="">
<input type="hidden" name="date" value="Sat Apr 3 11:09:04 2004">
<input type="submit" name="submit" value="submit">&nbsp;&nbsp;&nbsp;
<input type="reset" value="Clear Form">
</form>

Does it have to do with the "enctype-" attribute, maybe?
Thanks for your help.

VectorJ

4:12 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



The default enctype is application/x-www-form-urlencoded, so that may be the problem. I personally never use an enctype unless I'm doing a file upload, in which case I use the multipart/form-data type (and the CGI module to process it).

Give it a try without the enctype specified and see what happens.

brucec

6:41 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



M, purple martin was referring to the fact that GET is a QueryString and Post is a Form HTTP header.

Perl works great, but I use PHP, because GET and POST work the same in PHP. You don't have to use two different methods.

In PHP, post and get are still accessed with a dollar sigh prefix.

If you have ASP support, use
Request.QueryString(form variable name) for GET
and
Request.Form(form variable name) for GET