I have the script below, where I request information from a form. After
making sure that the from has the fields I need, I would like for it to
write
the information to a file. How do I pass the CGI fields to another function?
Thanks
Carlos-- Script so far
#!/usr/local/bin/python
"""
"""
import cgi,sys,os,string
#import smtplib
form = cgi.FieldStorage() # CGI parsing function
def SendError(field):
print """
Content-Type: text.html\n
<html>\n<head>
<title>CGI Error(s)</title>
The following errors were detected in the form:
error_list
Please go back using the back button in your browser and corrent the
errors before submitting the form again.
</body>\n</html>"""
def WriteData():
# Should I put the fomr variable here in order to be able to write the form
fields to a file?
file = open(FormData.txt,a)
# How do I pass the fields of the form to this function so I can write them
on
# a file?
# Change this value for your specific form
required = ['name', 'email', 'comment']
for item in required:
if not form.has_key(item):
error_list += item
if error_list != "":
SendError(error_list)
else:
WriteData()