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

I am trying to submit to this forum, as far as I can see the values for the fields are correct but for some strange reason I am getting 'illegal value' for field message
use strict; use warnings; use WWW::Mechanize; my $agent = WWW::Mechanize->new(); my $subject = 'help pls'; my $message = 'where can I download this'; my $url ='http://www.aegisstudios.net/modules.php?mop=modload&name=Spl +att_Forums&file=newtopic&forum=8'; $agent->get($url); $agent->agent_alias( 'Windows IE 6' ); my @urls = $agent->find_all_links(); foreach my $link(@urls) { #print "Link: ", $link->url(), "\n"; #$agent->field('message' => $message, $link->url()); $agent->set_visible($subject, $message, $link->url()); $agent->form_name("post"); $agent->click(); }

Replies are listed 'Best First'.
Re: Submitting a form
by planetscape (Chancellor) on Nov 30, 2005 at 01:26 UTC

    The very first thing I would try is using a module such as HTTP::Recorder or WWW::Mechanize::Shell to record a successful manual form submission. The output of HTTP::Recorder, for instance, can be "dropped" right into your WWW::Mechanize scripts.

    Also essential for finding out what is really happening behind the scenes between server and browser is a protocol analyzer such as Ethereal.

    Another thing you might check is the HTML source of the site you are accessing to make sure you're not trying to put 20 chars into a field with a limit of 10, for example...

    HTH,

    planetscape
Re: Submitting a form
by johnnywang (Priest) on Nov 30, 2005 at 06:22 UTC
    I took a quick look at the page, not sure what your foreach loop is for, but I think you want something like:
    $agent->form("coolsus"); $agent->field("message", $message); $agent->field("subject", $subject); $agent->click("submit");