Professional Web Applications Themes

form content passing - PERL Beginners

Hello, I am having troubles getting started. I have a Unix (Solaris 9) cgi script which ps a form, processes the contents of the form, and then sends it to a Windows ASP script for more processing and insertion into a Access database. I haven't been able to determine the correct or most efficient way of sending all the form contents to the ASP script. In the code below, hidden_1 and hidden_2 are only for testing. The actual fields will number over 40 and have labels such as first_name, last_name, email_address, etc. The code below does work with the two ...

  1. #1

    Default form content passing

    Hello,

    I am having troubles getting started. I have a Unix (Solaris 9) cgi
    script which ps a form, processes the contents of the form, and then
    sends it to a Windows ASP script for more processing and insertion into
    a Access database. I haven't been able to determine the correct or most
    efficient way of sending all the form contents to the ASP script. In
    the code below, hidden_1 and hidden_2 are only for testing. The actual
    fields will number over 40 and have labels such as first_name,
    last_name, email_address, etc. The code below does work with the two
    test variables. I have omitted warnings and strict etc for clarity.

    Any help will be appreciated.

    Lawrence Adamiec
    Unix Manager
    Rm. 525B
    565 W. Adams St.
    Chicago-Kent College of Law
    Illinois Institute of Technology
    Chicago, Illinois
    312-906-5301

    ***** Start of Code *************

    &ReadP;

    my $ua = LWP::UserAgent->new;

    my $req = POST 'http://some_server/test2.asp',
    [ hidden_1 => 'XXaaXX',
    hidden_2 => $in{'hidden_2'}
    ];
    my $content = $ua->request($req)->as_string;
    Larry Guest

  2. #2

    Default Re: form content passing


     

    Oi, first off don't do this

    use CGI 'param';

    instead

    then instead of $in{'hidden_2'} you get the value from param('hidden_2')

    So

    hidden_2 => $in{'hidden_2'}

    becomes

    my $hid2 = param('hidden_2');

    ....

    hidden_2 => $hid2

    See
    perldoc CGI
    for details

    Also:

    use strict;
    use warnings;

    always!!
     

    see
    perldoc LWP::UserAgent
    for details about how to POST values to a url.

    HTH :)

    Lee.M - JupiterHost.Net
    JupiterHost.Net Guest

  3. #3

    Default Re: form content passing

    Larry Adamiec wrote: 

    No it does not. It results in a compilation error.

    If you want help with a problem, please post a short but *complete*
    program that illustrates the problem you are encountering! In this
    case it probably should include the HTML form. Also, don't retype the
    code, but copy and paste into the message the code you have actually
    tried to execute.
     

    Bad idea. You'd better include them in order to demonstrate that you
    let Perl give you some basic help with debugging.
     

    That line indicates that you are using an old library, or possibly a
    subroutine derived from that library, for parsing form data. It would
    be a good idea to replace it with e.g.:

    use CGI;
    my %in = new CGI->Vars;

    Please acquaint yourself with the docs for CGI.pm:

    perldoc CGI
     

    Assuming that the form data have been stored in %in, you might be able
    to do something like:

    my $url = 'http://some_server/test2.asp';
    my $req = new HTTP::Request(post => $url);
    $req->content_type('application/x-www-form-urlencoded');
    $req->content( [ %in ] );

    Please study the libwww-perl docs, such as:

    perldoc LWP
    perldoc lwpcook

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  4. #4

    Default Re: form content passing

    Larry Adamiec wrote: 

    No it does not. It results in a compilation error.

    If you want help with a problem, please post a short but *complete*
    program that illustrates the problem you are encountering! In this
    case it probably should include the HTML form. Also, don't retype the
    code, but copy and paste into the message the code you have actually
    tried to execute.
     

    Bad idea. You'd better include them in order to demonstrate that you
    let Perl give you some basic help with debugging.
     

    That line indicates that you are using an old library, or possibly a
    subroutine derived from that library, for parsing form data. It would
    be a good idea to replace it with e.g.:

    use CGI;
    my %in = new CGI->Vars;

    Please acquaint yourself with the docs for CGI.pm:

    perldoc CGI
     

    Assuming that the form data have been stored in %in, you might be able
    to do something like:

    my $url = 'http://some_server/test2.asp';
    my $req = new HTTP::Request(post => $url);
    $req->content_type('application/x-www-form-urlencoded');
    $req->content( [ %in ] );

    Please study the libwww-perl docs, such as:

    perldoc LWP
    perldoc lwpcook

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  5. #5

    Default RE: form content passing

     
    >
    > Oi, first off don't do this
    >
    > use CGI 'param';
    >
    > instead[/ref]


    I have used CGI 'param' before. Don't know why I didn't use here.

     
    >
    > see
    > perldoc LWP::UserAgent
    > for details about how to POST values to a url.[/ref]

    Thanks for the info. I'll keep reading and try to figure things out.

    Larry
    Larry Guest

Similar Threads

  1. Error Passing Form Value
    By d088 in forum Macromedia ColdFusion
    Replies: 2
    Last Post: March 24th, 09:20 PM
  2. passing password from form to form
    By Hi Ho in forum PHP Development
    Replies: 1
    Last Post: February 5th, 01:03 AM
  3. entire form content
    By Christian in forum PHP Development
    Replies: 3
    Last Post: November 23rd, 05:41 PM
  4. passing arguments from web-form to win-form
    By Mart Rogers in forum ASP.NET Web Services
    Replies: 6
    Last Post: July 9th, 07:18 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139