[Tutor] Form values
Rich Lovely
roadierich at googlemail.com
Sat Jul 18 00:49:23 CEST 2009
2009/7/17 <keithabt at beyondbb.com>:
> 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()
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
There is an error before there:
In the line
entry = name + '|' + email + '|' + address + '|' + telephone + '|' +
IpAddress + '|' + Time + "\n"
None of the names are defined except IpAddress and Time. Everything
else has "the_" prepended when it is defined earlier in the code, but,
as you can see, not in the line were they are accessed.
--
Rich "Roadie Rich" Lovely
There are 10 types of people in the world: those who know binary,
those who do not, and those who are off by one.
More information about the Tutor
mailing list