Hi there Perlmonks!
I have a small perl problem, I can't seem to solve. And I was hoping, someone could help me on it.
I want to loginto a forum and then post a thread there.
This should be done with WWW::Mechanize.
The page source of the login site looks like this:
<form action="http://www.forum.com/" method="get" onsubmit="return this.gotopage()" id="pagenav_form"> <input type="text" class="bginput" id="pagenav_itxt" style="font-size:11px" size="4" /> <input type="button" class="button" id="pagenav_ibtn" value="Go" /> </form> </td> </tr> </table> </div> <br /> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr valign="top"> <td width="180" > <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center"> <thead> <tr> <td class="tcat"><strong>Wellcome</strong></td> </tr> </thead> <tbody> <tr> <td class="alt1"> <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center"> <tr> <td> <form action="/login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)"> <script type="text/javascript" src="clientscript/vbulletin_md5.js?v=382"></script> <table cellpadding="0" cellspacing="3" border="0" align="center"> <tr> <td align="center"><input type="text" class="namefield" style="font-size: 11px;width:105px;" name="vb_login_username" id="navbar_username" accesskey="u" tabindex="101" value="Username" onblur="if (this.value == '') this.value = 'Username';" onfocus="if (this.value == 'Username') this.value = '';" /></td> </tr> <tr> <td align="center"><input type="password" class="passfield" style="font-size: 11px;width:105px;" name="vb_login_password" id="navbar_password" tabindex="102" onblur="if (this.value == '') this.value = 'Password';" onfocus="if (this.value == 'Password') this.value = '';" /></td> </tr> <tr> <td class="smallfont" nowrap="nowrap" align="center" style="padding-left:-3px;"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />Stay signedin?</label></td></tr> <tr> <td align="center" style="padding:5px;"><input type="submit" class="button" value="Login" tabindex="104" title="Type in your username and password here!" accesskey="s" /></td> </tr> </table>
My try to login:
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use LWP;
my $user = 'name';
my $pass = 'xx123xx';
my $url = "http://www.forum.com";
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_name("signin_form");
$mech->field('Username' => $user);
$mech->field('Password' => $pass);
$mech->submit();
I have tried many different things but i can not get it to work...
And also this is wrong.
Can anyone help?
Thank you! :)