Help with CGI

lost lost at
Sun Apr 13 21:41:45 CEST 2003

Hi there, 
I'm trying to write a program which prints the html page, and when form
data has been submitted, it prints the html again, but with the keys and
values from the form.
here's the code i have so far:(bottom of post)

I can't get the "for key in form.keys():" part to run....
I'd also like to ONLY print the html if there are no values in the cgi, so
I'd need something like:
if form.keys == [""]: #if there are no keys submitted
	do this...

any help for what I need to do? 

print "Content-type: text/html\n\n"                                                                                                                                  
#get cgi data into a list...
import cgi
form = cgi.FieldStorage
print """
<form name=\"login_form\" method=\"post\" action=\"http://pertelotte/cgi-bin/\">
<table width=\"85%\" align=\"right\" border=\"1\">
                <td width=\"40%\" align=\"right\"><font size=\"-2\">Enter your details:</font></td>
                <td align=\"right\"><font size=\"-2\">Username: </font><input type=\"text\" name=\"uname\" size=\"15\"></td>
                <td align=\"right\"><font size=\"-2\">Password: </font><input type=\"password\" name=\"pword\" size=\"15\"></td>
                <td colspan=\"2\" align=\"right\">
                <input type=\"submit\" name=\"submit\" value=\"Login\">
<hr width=\"100%\">
for key in form.keys():
        print key
print """

More information about the Python-list mailing list