List form data : form « CGI Web « Python Tutorial






#!/usr/local/bin/python
import cgi

def header(title):
    print "Content-type: text/html\n"
    print "<HTML>\n<HEAD>\n<TITLE>%s</TITLE>\n</HEAD>\n<BODY>\n" % (title)

def footer():
    print "</BODY></HTML>"

form = cgi.FieldStorage()
formkeys = form.keys()
formkeys.sort()
header("")

print '<UL>'
for k in formkeys:
    print '<LI>' + k + ':' + form[k].value + '</LI>'
print '</UL>'

footer()








22.3.form
22.3.1.A Simple Form
22.3.2.Creating Self-Posting CGI Scripts
22.3.3.Static Form Web Page (friends.htm)
22.3.4.Demonstrates get method with an XHTML form
22.3.5.Demonstrates post method with an XHTML form
22.3.6.Demonstrates use of cgi.FieldStorage with an XHTML form
22.3.7.List form data
22.3.8.Login form
22.3.9.Receiving Data from an HTML File