|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hi.
I´m 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. URL |
|
#2
|
||||
|
||||
|
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..." |
|
#3
|
|||
|
|||
|
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.)
|
|
#4
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > why STDIN doesn't work?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|