Demonstrates use of cgi.FieldStorage with an XHTML form : Form : CGI Web PYTHON TUTORIALS


PYTHON TUTORIALS » CGI Web » Form »

 

Demonstrates use of cgi.FieldStorage with an XHTML form


#!c:Pythonpython.exe

import cgi

def printHeadertitle ):
   print """Content-type: text/html

<?xml version = "1.0" encoding = "UTF-8"?>    
<html xmlns = "http://www.w3.org/1999/xhtml">
<head><title>%s</title></head>

<body>""" % title
printHeader( "Using cgi.FieldStorage with forms" )
print """<paragra[h>Enter one of your favorite words here:<br /></paragraph>
   <form method = "post" action = "fig06_10.py">
      <paragraph>
      <input type = "text" name = "word" />
      <input type = "submit" value = "Submit word" />
      </paragraph>
   </form>"""

form = cgi.FieldStorage()

if form.has_key( "word" ):
   print """<paragraph>Your word is:  
      <span style = "font-weight: bold">%s</span></paragraph>""" % cgi.escape( form[ "word" ].value )

print "</body></html>"



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo CGI Web
» Form