Results 1 to 4 of 4

Thread: Problem of form that sends a get instead of post

  1. #1
    Join Date
    Jul 2009
    Posts
    77

    Problem of form that sends a get instead of post

    I have a little problem with the module HTML::Form. I connect first by an http address that requires a login and password. I get the form and return it completed.

    Following this, the server sends me that the page I specified in the url ($base). But this page, recovered in the variable $res2, is in fact a form that I'd like to complete my script. So I write this line: my $form2 = HTML::Form -> parse ($res2 -> content), but the shell gives me the following error: HTML::Form:: parse: No $base_url provided at scriptHttp2qua.pl line 39

    I know it must normally specify the url, but it is useless in this case. If I specify the url, I have the following error: Can not call method "value" on an undefined value at scriptHttp2qua.pl line 40.

    Does someone can help me get the second form in $res2 (which includes the header + form)?

    In addition, cookies can not be erased at the end of my script. Does anybody know why? Should we close the connection properly?

    Here's the code so you can see what I want to do:

    PHP Code:
    #!/usr/bin/perl -w
    use strict;
    use 
    LWP::UserAgent;
    use 
    HTML::Form;
    use 
    HTTP::Cookies;
    use 
    LWP::Simple;
    # personal settings
    my ($user$pass ) = qw(name password);
    my $base 'http://X.X.X.X/RTIR/Create.html?Queue=Incidents';
    my $req;
    my $cookies 'cookies.txt';
    #initialization of the agent
    my $ua LWP::UserAgent->new(agent => 'Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.14)',
    cookie_jar => HTTP::Cookies->new(
        
    file           => $cookies,
                
    autosave       => 1,
                
    ignore_discard => )
    );
    # creation of the request
    $req HTTP::Request->newGET => "$base);
    # executes the query and receives the response
    my $res $ua->request($req);
    die 
    $res->status_line if not $res->is_success;
    # form the login
    my $form = ( HTML::Form->parse($res->content$base));
    # fills the fields
    $form->find_input('user')->value($user);
    $form->find_input('pass')->value($pass);
    # validate and return the form
    my $res2 $ua->request$form->click );
    print 
    $res2->content;
    my $form2 HTML::Form->parse$res2->content ); 

  2. #2
    Join Date
    Nov 2008
    Posts
    1,054

    Re: Problem of form that sends a get instead of post

    Why do not you try with:
    Code:
    my $form2 = HTML::Form->parse( $res2->content, $base);
    it seems quite logical priory.

    If you do not keep cookies, why you did "autosave => 1" in the creation parameters of the cookie.

    You can always clean up with a call to $cookie_jar-> clear() [which is fully documented in HTTP::Cookies]

  3. #3
    Join Date
    Jul 2009
    Posts
    77

    Re: Problem of form that sends a get instead of post

    Since I had a bug when I added the $base url my $form2 = HTML::Form-> parse ($res2-> content, $base); that's why I posted a message because I did not know how. But it's good actually, the error was from another line. It works so as

    For cookies, I stopped the recording. But, if I recorded, I must do a test to open direct connection with the cookie if this is right? I can not do this test properly, I have some bugs then. It said that "value" in the search for data in the form is "undefined". Finally, I think I will not save cookies as that is far simpler.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,054

    Re: Problem of form that sends a get instead of post

    No problem if it's in my strings. It is a module that can easily automate the connection to a web server in which we must return completed forms.

    One suggestion: try $bot-> post() and if not working then try with $ bot-> SUBMIT_FORM (...) with the correct parameters.

Similar Threads

  1. Replies: 5
    Last Post: 25-05-2011, 10:21 PM
  2. Problem in form submission
    By Udyan in forum Software Development
    Replies: 4
    Last Post: 30-01-2010, 04:28 PM
  3. Problem in PHP form
    By Sam12 in forum Software Development
    Replies: 3
    Last Post: 06-05-2009, 10:46 PM
  4. Problem with Motherboard Post
    By Aakarshan.d in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 27-02-2009, 08:06 AM
  5. Problem reloading MDI child form in main form.
    By AFFAN in forum Software Development
    Replies: 3
    Last Post: 30-01-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,475,960.93308 seconds with 16 queries