Why doesn't this work? (CGI)

Forgot to mention that method="GET" doesn't change anything. It appends the form data to the url, but drops the key=val from the url in the process.

···

I don't know the internals of the CGI module well, but you're mixing a query string and a HTTP POST. Does it work if you change method=post to method="GET"?

I'm sure there's a way to get both the query string and the posted variables out, though you might need to do some manual parsing of the query string. In general though, you shouldn't be mixing query string arguments and POSTs.

Ben

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

See ruby-talk:96394 for the same problem and example of solution.

The problem is that variables appear in CGI#params from QUERY_STRING or from
POST data, but not from both at one time. You need to parse QUERY_STRING by
yourself and then merge that with current #params content.

···

On Thursday 24 June 2004 04:08, Orion Hunter wrote:

Forgot to mention that method="GET" doesn't change anything. It appends
the form data to the url, but drops the key=val from the url in the
process.

--
sdmitry -=- Dmitry V. Sabanin
MuraveyLabs.
Spam Here -> postmaster@sco.com

Hello,

The problem is that variables appear in CGI#params from QUERY_STRING or from
POST data, but not from both at one time. You need to parse QUERY_STRING by
yourself and then merge that with current #params content.

I maintain an alternate CGI library, of debatable merit (in another thread).

If a CGI library merged query and post data, how should the data be merged? Should POST overwrite GET? Should POST and GET be added together, returning multiple values if both contain the same keys?

I think when the keys in GET are different from the keys in POST, the two (maybe) should be merged. But about when keys overlap? This is the example which bothers me:

http://blahblahblah.com/wiki.rb?page=HomePage

<form method="post">
<input type="hidden" name="page" value="HomePage">
<textarea name="content"></textarea>
<input type="submit">
</form>

I want "page" to be "HomePage". But on submit, it becomes "HomePage,HomePage". I don't really think the library is helping me by merging things together.

And the library is harder to write.

And since I write the library, this ends up feeling bureaucratic and not worth it.

To simplify, to me that's why that aspect of CGI doesn't work.

~ Patrick May

···

On Wednesday, June 23, 2004, at 11:28 PM, Dmitry V. Sabanin wrote:

I would argue that you should have some standard way of overwriting
(i.e. either post or query takes precedence), but also have a separate
way to get JUST the post args or just the query args, so you'd have
something like:

args = cgi.args()
p_args = cgi.args_post()
q_args = cgi.args_query()

That way, he who doesn't care where the data is coming from can just
call args, but when you need a more specific way to look, you ask for
either the query args or the post args (or more likely, grab both into
two separate hashes)

···

On Thu, 24 Jun 2004 14:42:01 +0900, Patrick May wrote:

Hello,

On Wednesday, June 23, 2004, at 11:28 PM, Dmitry V. Sabanin wrote:

The problem is that variables appear in CGI#params from QUERY_STRING
or from
POST data, but not from both at one time. You need to parse QUERY_STRING by
yourself and then merge that with current #params content.

I maintain an alternate CGI library, of debatable merit (in another thread).

If a CGI library merged query and post data, how should the data be
merged? Should POST overwrite GET? Should POST and GET be added
together, returning multiple values if both contain the same keys?

--
Rando Christensen
eyez@illuzionz.org