submitting a form when two forms with the same name

G

Guest

Trying to submit the second form, when there are two forms on the page both
called "submit" using www::Mechanize and Html::Form

the first form html is: <input type="submit" name="submit" value="Go" />

The second form's: <input type=submit name=submit value=" S E N D ">

#After filling in my login details with and getting positive checks for
username and password filled in:

#! /usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;


my $mech WWW::Mechanize->new();

$mech->get("http://localhost/login.cgi");

foreach($mech->forms()){
if (defined $_->find_input('username'))
$_->value('username',"username");
if($mech->success){print "Username filled in \n";}else{print " $! \n"}
$_->value('password',"password");
if($mech->success){print "password filled in \n";}else{print " $! \n"}

}
}

$mech->submit("submit"); #I have also tried $_->click("submit"); but all
submitted the first form and not the second
 
B

Ben Morrow

Quoth "Nospam said:
Trying to submit the second form, when there are two forms on the page both
called "submit" using www::Mechanize and Html::Form

the first form html is: <input type="submit" name="submit" value="Go" />

The second form's: <input type=submit name=submit value=" S E N D ">

Try

$mech->click_button(value => ' S E N D ');

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top