[Tutor] sending to file

keithabt at beyondbb.com keithabt at beyondbb.com
Fri Jul 17 20:52:07 CEST 2009


I have a form and script that works. I can enter values into the fields, however 
the data will not show up on the server in the text file. The properties for the 
file is 0777. Can the form cause this problem?

<form method="post" action="http://web.nmsu.edu/~keithabt/cgi-bin/07_index.cgi">
<UL><I Align="center">Please feel out the entire form:</I></UL>
<center><table width="50%" >
<TR><TD align=right width="20%">Name:</TD>
    <TD><input type=text Name=name size=50 value="name"></TD></TR>
<TR><TD align=right> Email Address:</TD>
	<TD><input type=text Name=email size=50 value="email"></TD></TR>
<TR><TD align=right> Mailing Address:</TD>
	<TD><input type=text NAME=address size=50 value="address"></TD></TR>
<TR><TD align=right> Telephone Number:</TD>	
    <TD><input type=text NAME=telephone size=50 value="telephone"></TD></TR>
<TD><input type="submit" name="submit" value="Submit:"></TD></TR>
</table></center>
</form>
</body>
</html>
"""
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