Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: CGI - How to use upload_hook and query the query string ?

by ikegami (Pope)
on Feb 07, 2006 at 18:22 UTC ( #528586=note: print w/replies, xml ) Need Help??

in reply to CGI - How to use upload_hook and query the query string ?

The hook needs to be called when the request is being parsed (i.e. in new), and the request needs to be parsed in order to know what parameters were supplied. .

Fortunately, the QUERY_STRING is parsed before the body is parsed, so you can use param to check parameters from the QUERY_STRING inside of your hook. Unforunately, the CGI request is not passed to the hook, so you'll have to store the CGI request in a "global":

my $cgi; sub hook { return if not $cgi->param(...); my (...) = @_; ... } $cgi = CGI->new(\&hook);

Replies are listed 'Best First'.
Re^2: CGI - How to use upload_hook and query the query string ?
by cees (Curate) on Feb 07, 2006 at 21:56 UTC

    I thought that by default did not parse the QUERY_STRING if it was a POST request... You actually have to edit the code to get it to parse and combine both the GET and POST parameters together.

    Search the source for for the string "Some people want to have their cake and eat it too".

      Your right. I looked at the source, but I looked too quickly and mistook something else for the parsing of QUERY_STRING. They'll have to modify their or use my alternate solution.
        I've gone down the route of putting the parameters in the URL action of the form as simple query paramaters which seems to work just fine. Many thanks for all the suggestions.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://528586]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2018-06-23 22:01 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.