[Tutor] Form values

keithabt at beyondbb.com keithabt at beyondbb.com
Fri Jul 17 18:43:08 CEST 2009


Hi, I am reading values from a form and writing them to a text file. I keep getting 
a syntax error for outfile=open("filename", "a")I cant see it, does any body else.


fileName = "requests.txt"
# Create instance of FieldStorage 
Form = cgi.FieldStorage()

# Get data from fields
if Form and Form['submit'].value == "Submit":
	
	the_name = Form.getvalue('name')
	the_email = Form.getvalue('email')
	the_address = Form.getvalue('address')
	the_telephone = Form.getvalue('telephone')
	
    
	IpAddress =  cgi.escape(os.environ["REMOTE_ADDR"]);
	Time = "(time.localtime()):", time.asctime(time.localtime())

	entry = name + '|' + email + '|' + address + '|' + telephone + '|' + 
IpAddress + '|' + Time + "\n"




	outfile=open("fileName", "a")
	outfile.write(entry)
	outfile.close()



More information about the Tutor mailing list