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

I've got a form that uses POST and has three image buttons that act as submit buttons. Clicking on one of the images submits the form and sends you to a certain page associated with the image you chose. WWW::Mech is unavailable. I was told that I must send this in the header:

Input_tag_name.x=0&Input_tag_name.y=0

Where the Input_tag_name is the name value of the image I want. Okay, but how do I use headers when my code looks like this:

my $browser = LWP::UserAgent->new; my $response = $browser->post( 'https://www.whatever.com/asdf.cgi', [ 'id' => $id, 'passwd' => $pass, ], ); die "Error: ", $response->status_line unless $response->is_success;

In other words, I want to send the headers and the rest of the POST data as shown above. Do I need to use a separate module or can I do this with LWP? Thanks.

Replies are listed 'Best First'.
Re: LWP & image submit buttons
by neuroball (Pilgrim) on Jan 18, 2004 at 06:00 UTC

    You already use the right code and also send information using the post header. The information you already send is id and passwd.

    The only thing to make the script work like you want it, is to add the other key/value pairs to the header as shown in the code below.

    my $response = $browser->post( 'https://www.whatever.com/asdf.cgi', [ 'id' => $id, 'passwd' => $pass, 'Input_tag_name.x' => 0, 'Input_tag_name.y' => 0, ], );

    /oliver/

Re: LWP & image submit buttons
by pg (Canon) on Jan 18, 2004 at 06:17 UTC

    Try this:

    my $response = $browser->post( 'https://www.whatever.com/asdf.cgi', [ 'id' => $id, 'passwd' => $pass, 'Input_tag_name.x' => 0, 'Input_tag_name.y' => 0 ], );

    UserAgent will put this into the form you want: Input_tag_name.x=0&Input_tag_name.y=0

    "I was told that I must send this in the header"

    I don't think this is precise, the data you post goes to the content, not the header. For get, it goes to the header.