[ back to toc ]

CGI Output

Date: 2002/05/23 11:22

Q:
I work for the library and need some help on a form that will survey our
users on our site about their zip codes. The problem I am having is the
output of the form. I would like the data to be sent to a text file on
submission and each submission will populate the text file. The form
submits fine (without errors), but the text file generated is blank.

This is the code I am using to call the file:
# this is where the info will be written to - you need to specify a real
directory
$file ="$ENV{DOCUMENT_ROOT}/files/zip_results.txt"; #must be read/writable

This is the code where the output format is defined:
#print "Content-type: text/plain\n\n ";
open(OUTPUT, ">>$file");
print OUTPUT "$contents{'zip'}\n";

close (OUTPUT);
exit;

Any ideas why the text file isn't populating?
A:
Not really. At least nothing that is an apparent error. Be aware that the
CGI script is ran by a user, which is usually called www-data or nobody or
similar. This is the user, who has to have the right to write the file
'zip_results.txt'

Also the directory containing the file should have the appropriate
permission.

regards,
Peter

[ back to toc ]