#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Puerto Vallarta, Jalisco, Mexico
    Posts
    3
    Rep Power
    0
    Hi.

    Im a new user of perl and I need to use POST to send data to a perl program.

    I follow diferents examples and I can't print the values of the form.

    I think that I'm grong in STDIN.

    The code that I am using is the next:

    -------------html form---------
    <form method=POST action="test4.pl">

    <input type="text" name="email">
    <input type="text" name="envio2">

    <input type="submit" value="submit">
    </form>
    ---------------------------------

    -------perl program--------------
    #!D:InetPubwwwrootclientesnettimesartnet
    print "Content-type: text/htmlnn";

    &parse_form;

    sub parse_form {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<!--(.|n)*-->//g;
    $value =~ s/<([^>]|n)*>//g;
    $FORM{$name} = $value;
    }
    }
    ----------------------------------

    Thanks for your help and sorry about my english.
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    grusein,

    just try the following .You have to print the parsed values from your form like $FORM{'email'}.


    #!/usr/local/bin/perl

    print "Content-type: text/htmlnn";

    &parse_form;

    print "Email:".$FORM{'email'};
    #print email here

    sub parse_form {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<!--(.|n)*-->//g;
    $value =~ s/<([^>]|n)*>//g;
    $FORM{$name} = $value;
    }
    }

    Good Luck!!

    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    You don't have to use $FORM{'email'}... you can use $FORM{email} (no single quotes). I'm only mentioning this to save some confusion (because you're parse routine doesn't have those quotes in them.)
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Puerto Vallarta, Jalisco, Mexico
    Posts
    3
    Rep Power
    0
    I include the print "Email2: ".$FORM{'email'}; with and wihthout quotes and my var is empty.
    Do you thing that something is wrong in the server of my ISP?
    Is working over Windows NT and Perl 5.003_07.
    If I use GET in the form, I can see all the data, but when I use POST, I can read any thing.
    Thanks for your time.


IMN logo majestic logo threadwatch logo seochat tools logo