Getting WWW::Mechanize to submit a form

Getting WWW::Mechanize to submit a form

am 13.09.2007 17:58:07 von Amer Neely

I'm trying to use this module to populate and submit a form on a remote
server, but apparently it is not doing either.

-------------------------- 8< ---------------------------
#! /usr/bin/perl
use strict;
use warnings;

use lib (
'/home/usr241/cgi-bin/PerlMods/WWW-Mechanize-1.18/lib',
'/home/usr241/cgi-bin/PerlMods/libwww-perl-5.808/lib',
'/home/usr241/cgi-bin/PerlMods/HTML-Parser-3.56/lib/'
);
use WWW::Mechanize;
use HTML::Form;

my $mech = WWW::Mechanize->new();
my $url = "http://xxx.xxx.xxx./form.aspx"; # edited
my $name="form1";

$mech->get( $url );
die "Can't even get the home page: ", $mech->response->status_line
unless $mech->success;

print "Found $url
\n" if $mech->success();

$mech->form($name);

die "Can't get the form name: ", $mech->response->status_line
unless $mech->success;

print "Found '$name'
\n" if $mech->success();

$mech->field('txtFirstName',$Firstname); # previously defined
$mech->field('txtLastName',$Lastname); # previously defined

print "Populated '$name'
\n" if $mech->success();

my $results = $mech->submit();

print "Submitted '$name'
\n" if $mech->success();
print "\n";

-------------------------- 8< ---------------------------


When the script runs, it prints out everything as if there were no
errors. But the programmer running the form at the remote site is saying
nothing is coming through.

Can anyone see anything wrong with this code that would cause it to fail?

--
Amer Neely
w: www.webmechanic.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"Others make web sites. We make web sites work!"