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! :)

In reply to Login in to forum with Mechanize by KarlaCluft

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.