> Tommaso Torti wrote:
> > Hi all,
> > 
> > i'm using mod_perl in order to retrieve all keys from a POST request with:
> > 
> > my $request = Apache2::Request->new($r);
> > my $data = $request->param();
> > 
> > When i receive something like
> > key1=value1&key2=&key3=value3
> > $data contains all 3 keys
> > 
> > but with
> > key1=value1&key2&key3=value3
> > $data contains only 2 keys: key1 and key2&key3
> > 
> > Is there a way to retrieve all the 3 keys like the first case? Any 
> > suggestions?
> > Thank you,
> 
> As far as I know, there isn't a way, because the browser will not send any 
> data for an 
> input field that is empty in the <form>.
> 
> If you want to do that, then you would need some javascript inside the form, 
> which fills 
> the empty fields with some "dummy" sequence (like "--empty--"), before 
> posting the form.
> Then your module/script would need to catch such fields, and consider them as 
> empty.

        Interesting.  I suppose one could use the GET method to verify 
whether $request->param() shoots blanks or undefs.

        Filling in fields seems like a lot of work though, and using 
JavaScript to fill in those fields with dummy data won't be 
compatible with anything.  A better approach would be to just include 
a hidden input element with the same name at some point after the 
user's input field:

                <input type=hidden name=key2 value=--empty-->

        But, I'd rather use this approach instead, if possible:

                <input type=hidden name=key2 value="">

        The beauty of this solution is that calling $request->param() in 
scalar context returns the first value, but if the POST method really 
isn't passing along blanks then the hidden input element's value will 
be in first place instead.

        However, I strongly suspect that this really is not the right 
solution.

Randolf Richardson - rand...@inter-corporate.com
Inter-Corporate Computer & Network Services, Inc.
Beautiful British Columbia, Canada
http://www.inter-corporate.com/


Reply via email to