#!/Library/Frameworks/Python.framework/Versions/Current/bin/python
# L-20 MCS 275 Fri 29 Feb 2008 : use_forms.py
import cgi

def PrintHeader(title):
   """
   writes title and header of page
   """
   print """Content-type: text/html

<html>
<head>
<title>%s</title>
</head> 
<body>""" % title

PrintHeader("using forms")

print """<b>Enter a word</b>
   <form method = "post" method = "use_forms.py">
   <p>
     <input type = "text" name = "word">
     <input type = "submit">
   </p>
   </form>"""

form = cgi.FieldStorage()
if form.has_key("word"):
   print """<p>Your word is <em>%s</em></p>
   """ % form["word"].value

print "</body></html>\n"

