atnonis has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone!
I was trying to teach my self the WWW::Mechanize module and i wrote the following program.
#!/usr/bin/perl -w use strict; use WWW::Mechanize; use LWP::Simple; my $browser = WWW::Mechanize->new(); $browser->get("http://localhost"); $browser->form_number('1'); $browser->field("username_entered", 'root'); $browser->field("password_entered", 'antonis'); $browser->submit(); my $url_ = $browser->{uri}; my $url = getprint($url_);
when im running it, i get the following error(s):
<input> outside <form> at /usr/lib/perl5/site_perl/5.8.0/WWW/Mechanize +.pm line 811 <input> outside <form> at /usr/lib/perl5/site_perl/5.8.0/WWW/Mechanize +.pm line 811 .<br> .<br> .<br> <input> outside <form> at /usr/lib/perl5/site_perl/5.8.0/WWW/Mechanize +.pm line 811
i've read an document at Advent Calendar but...
Any help!?
Antonis!

Replies are listed 'Best First'.
Re: WWW:Mechanize (input not in form) problem
by Abigail-II (Bishop) on May 04, 2003 at 23:02 UTC
    That's not an error, it's a warning generated by HTML::Form, indicating the HTML is not correct; it has found and INDEX element that is not inside a FORM element.

    Abigail

      i still can't understand what is the problem. this is my html form code and i don't see anything "funny"
      <form method="POST" enctype="application/x-www-form-urlencoded" action +="myplace.pl"> <div align="right"> <div align="left"> Welcome to "Your Place"! </div> <br> <font size="2" color="red"><b><TMPL_VAR NAME="error_msg"></b></font> <br> <input type="text" name="username_entered" value=""><br>username<br> <input type="password" name="password_entered" value=""><br>password<b +r><br> <font size="1"> remember me &gt;</font><input type="checkbox" name="_c +heckcookie" value=""> <input type="submit" name="login" value="Log in"> </div> </form>
      can you figure out what is wrong!?

      Antonis!

        Adding to merlyn's reply, try running the complete page through an HTML validator, which should be able to tell you where the exact error is at.

        ----
        I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
        -- Schemer

        Note: All code is untested, unless otherwise stated

•Re: WWW:Mechanize (input not in form) problem
by merlyn (Sage) on May 07, 2003 at 15:32 UTC
    Add this right after your first get:
    print $browser->content; exit;
    The HTML you posted later in this thread, and in your scratchpad while we were discussing this in the chatterbox, could not have possibly generated those errors from HTML::Form. So now it's time to see what you're really getting.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      as i didn't expect this code print $browser->content; print out the index.htm, file not the one which is after a valid login. I still can't figure out what the problem is. Do you think the problem is ate <TMPL VAR>? i've writen it as a comment, i dont think it is but... who knows!? (i dont!)
      Antonis!