passing arguments from CGI to function

Steve Holden sholden at holdenweb.com
Sun Apr 22 14:11:59 EDT 2001


[posted and mailed]

Carlos:

A better-formatted version might be easier to debug!

regards
 Steve

"Carlos Araya" <elrond25 at MailAndNews.com> wrote in message
news:3AFCE8F4 at MailAndNews.com...
> CGI Error(s)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
\n 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. \n""" 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()
>





More information about the Python-list mailing list