Hi All,

Been tasked with an assignment that is kicking my butt. We have been asked
to write a py utilizing cgi to ask for simplistic web form guestbook
information (name and email). I think I am lost on whether or not my actual
py script needs to link to a cgi script or if I can do it all in a py
script. It needs to log entries to a text file and everytime I think I have
it working I go to my text file and it remains empty. I don't know if I can
post my script code in here so if I can not then my apologies forthcoming.
Any help or advice is most appreciated.

py script:

#!c:\python25\python.exe
import cgi, cgitb, os

temp = """
<html>
<body>
<form action=sample.cgi>
First Name: <input type=text name=fname><br>
Last Name: <input type=text name=lname><br>
Email:  <input type=text name=email><br>
<hr>
<input type=submit>
</form>
</body></html>


"""
path = 'c:\\file'
# Create instance of FieldStorage 
form = cgi.FieldStorage() 

# Get data from field 'name' 
fname = form.getvalue('fname') 

# Get data from field 'address' 
lname = form.getvalue('lname') 

# Get data from field 'email' 
email = form.getvalue('email')

if not os.path.isdir(path):
    os.mkdir(path)
    e=open(path + '\\' + 'logbook.txt','a')
    e.write("%s#%s#%s\n" % (fname,lname,email))
    e.close()
print 'Done'


What am I doing wrong? Been working on this two weekends in a row and the
assignment is already late.

Thanks,

TheSarge
-- 
View this message in context: 
http://www.nabble.com/Newbie-College-Student-tf4220394.html#a12006185
Sent from the Python - tutor mailing list archive at Nabble.com.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to