Hi All! I'm having big problem with a login form. I obviously use WWW::Mechanize, but the login button is not part of the form. Actually the webpage is this:
<table border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table border="0" cellspacing="10" cellpadding="0"> <form method="post" target="_top" action="../jsp/index.jsp +" name="TheForm" onSubmit="return sendForm();"> <input type="hidden" name="password" value="" /> <input type="hidden" name="rememberid" value="" /> <input type="hidden" name="pid" value="0"/> <input type="hidden" name="challenge" value="" /> <tr> <td><font face="Arial" size="2" color=#ffffff><b>&nbsp +;Nome utente</b></font></td> <td><input style="width:120px;" type="text" name="us +erid" size="15" maxlength="25" tabindex="1" value=""/></td> </tr> </form> <form method="post" target="_top" action="../jsp/index.jsp +" name="loginForm" onSubmit="return sendForm();"> <input type="hidden" name="userid" value=""/> <input type="hidden" name="rememberid" value=""/> <input type="hidden" name="pid" value="0"/> <input type="hidden" name="bla" value=""/> <tr> <td><font face="Arial" size="2" color=#ffffff><b>&nbsp +;Password</b></font></td> <td><input style="width:120px;" type="password" name=" +password" size="15" tabindex="2" maxlength="25" value=""/></td> </tr> </form> <tr> <td colspan="2" align="right"> <a href="javascript:clickLogin()" onMouseOver="ret +urn statusMsg('Login');" onMouseOut="return statusMsg();"><img src=". +./images/it/button_login.gif" border="0" alt="Login" tabindex="3"></ +a></td>
and my code is this:
$mech->form_number(1); $mech->set_fields ( 'userid' => $user) ; $mech->form_number(2); $mech->set_fields('password' => $password); $mech->form_number(1); $mech->submit_form(); #dont' work $mech->click(); #don't work $mech->follow_link( text_regex => qr/Login/i ); #don't work
i'have tried all combination of submit_form (with fields) & something similar, but i don't think these methods are suitable for pressing a link-image-button.. Is this because www::mechanize didn't support javascript? :| Tanx in advice so much!

In reply to WWW::Mechanize login by LordScinawa

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.