Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using WWW::Mechanize to fill in a checkbox

Status
Not open for further replies.

spyderco

Programmer
Jan 23, 2005
107
US
I need to know how to check the Remember Me checkbox on this form using
Code:
                       ><form method="post" action="login.php?sid=c51
+4c45f8ced1eae9f9eced24365bf48">
<table border="0" cellpadding="0" cellspacing="1" width="100%">
<tr> 
<td align="center"><span class="gensmall"> 
<input type="hidden" name="redirect" value="" />
Username:<br />
<input class="post" type="text" name="username" size="15" />
<br />
Password:<br />
<input class="post" type="password" name="password" size="15" />
<br />
</span> <table border="0" cellspacing="0" cellpadding="0">
<tr> 
<td><input class="text" type="checkbox" name="autologin" /></td>
<td class="gensmall">&nbsp;Remember me</td>
</tr>

My code is
Code:
#!/usr/bin/perl

use warnings;
use strict;

my $username = "test";
my $password = "test";

use CGI::Carp qw(fatalsToBrowser);

use [URL unfurl="true"]WWW::Mechanize;[/URL]
use CGI qw/:standard/;

my $browser = [URL unfurl="true"]WWW::Mechanize->new();[/URL]

$browser->get("[URL unfurl="true"]http://www.mwjz.com/phpbb/portal.php");[/URL]

$browser->form(1);

$browser->field("username", $username);
$browser->field("redirect", "");
$browser->field("autologin", "check");
$browser->field("password", $password);
$browser->click();

print header;
print $browser->content();

Which fails with
Code:
Illegal value 'check' for field 'autologin' at ...".
 
Code:
$browser->tick( "autologin", 1 );

Not sure about the value 1, if that doesn't work, try 0 or -1

--Paul

cigless ...
 
Code:
$browser->tick( "autologin", 1 );

Worked PERFECTLY, thanks PaulTEG!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top