File: class/Workbook/Examples/Lecture14/cgi1.txt

print "Content-type: text/html"   # HTML text follows
print                             # blank line: end headers
print "<TITLE>CGI script output</TITLE>"

form = cgi.FieldStorage()
form_ok = 0
if form.has_key("name") and form.has_key("addr"):
    if (form["name"].value != "" and 
        form["addr"].value != ""):
        form_ok = 1

if not form_ok:
    print "<H1>Error</H1>"
    print "Please fill in the name and addr fields."
    return
...more form processing here...



[Home page] Books Code Blog Python Author Train Find ©M.Lutz