Demonstrates get method with an XHTML form : form « CGI Web « Python Tutorial

Home
Python Tutorial
1.Introduction
2.Data Type
3.Statement
4.Operator
5.String
6.Tuple
7.List
8.Dictionary
9.Collections
10.Function
11.Class
12.File
13.Buildin Function
14.Buildin Module
15.Database
16.Regular Expressions
17.Thread
18.Tkinker
19.wxPython
20.XML
21.Network
22.CGI Web
23.Windows
Python Tutorial » CGI Web » form 
22.3.4.Demonstrates get method with an XHTML form
#!c:\Python\python.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 'get' with forms" )
print """<p>Enter one of your favorite words here:<br /></paragraph>
   <form method = "get" action = "fig06_08.py">
      <paragraph>
      <input type = "text" name = "word" />
      <input type = "submit" value = "Submit word" />
      </paragraph>
   </form>"""

pairs = cgi.parse()

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

print "</body></html>"
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.