Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RE: Asking for help from anyone...

by c-era (Curate)
on Jul 11, 2000 at 15:16 UTC ( #21954=note: print w/replies, xml ) Need Help??


in reply to Asking for help from anyone...

Original code:
read(STDIN,$form_data,$ENV{'CONTENT_LENGTH'}); open (FILE,""something.log"); print $form_data; close(FILE);
First, you are not doing anything with the file. Second, if you want to send html back you need to print "Content-type: text/html\n\n"
# Get form information if ($ENV{'REQUEST_METHOD'} eq "GET") { # GET Method $form_data = $ENV{'QUERY_STRING'}; } elsif ( $ENV{'CONTENT_LENGTH'} > 0 ) { # POST Methond read(STDIN, $form_data, $ENV{'CONTENT_LENGTH'}); } else { exit; } # Error handling # To print the form info to a file open (FILE,">>something.log"); # Open the file in append mode flock (FILE,2); # Exclusive lock print FILE $form_data; # Print the form to the file # To print the file as a responce open (FILE,"<something.log"); # Open the file in read mode flock (FILE,1); # Sharded lock print "Content-type: text/html\n\n"; # Print HTTP header print <FILE>; # Print file close(FILE); # Close and unlock the file
Hope that helps.

PS Not everyone can use CGI.pm. Some places do not like extra moduals to deal with, so it is always helpful to know the raw way of doing something.

Replies are listed 'Best First'.
RE: RE: Asking for help from anyone...
by le (Friar) on Jul 11, 2000 at 16:00 UTC
    I thought CGI.pm is part of the standard Perl distribution?!

      It is. And has been since 5.004_04. Anyone still using a version of Perl earlier than that is beyond help.

      And besides, I'd rather deal with extra modules than a dozen programmers each implementing their own CGI parameter parsing routine - each with its own little bugs.

      --
      <http://www.dave.org.uk>

      European Perl Conference - Sept 22/24 2000, ICA, London
      <http://www.yapc.org/Europe/>
RE: RE: Asking for help from anyone...
by plaid (Chaplain) on Jul 12, 2000 at 00:20 UTC
    This is incorrect. What this will do is print into the file the exact thing that the poster got: a bunch of hyphens followed by a bunch of numbers/letters. Multipart form data does not work by reading in the CONTENT_LENGTH amount of bytes. Check out rfc 1867 for a description.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://21954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-05-28 22:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?