
perlkid
stranger
Jul 3, 2000, 12:14 PM
Post #2 of 7
(3520 views)
|
Re: Need to accept values from a form and write them to a file
[In reply to]
|
Can't Post
|
|
Use This At the top of your script ######################################## read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @cgiPairs = split(/&/,$buffer); foreach $cgiPair (@cgiPairs) { ($name,$value) = split(/=/,$cgiPair); $value =~ s/\+/ /g; $value =~ s/%(..)/pack("c",hex($1))/ge; $form{$name} .= "\0" if (defined($form{$name})); $form{$name} .= "$value"; } ######################################## This code stores the form values into $form{'value'}. Now name your forms. For the banner source I'd name the form "bsource". Then the value is stored into $form{'bsource'}. Make sure you point the form action to your script also. Now open the data file. open(DB, ">>/full/path/to/file.db"); print DB "$form{'burl'}|$form{'bsource'}|so on|and so on|"; close(DB); The >> means to append (write to the end of the file), you can also use > to overwrite and < to simply read only. That's it. perlkid [This message has been edited by perlkid (edited 07-03-2000).]
|