Question using CGI in Python

Shane Anglin shane.anglin at
Tue Aug 28 21:39:58 CEST 2001

In very abbreviated form:  This is not a functional anything... I have to
use 3 pages to accomplish this task using HTML, Python, and PostgreSQL.

1- is used to submit a variable that is passed to
2 - gets variable from, then, depending on variable value,
pulls other content from database and creates a HTML form for entering more
3 - should get data that was submitted from

My problem is getting to place the variable sent from and
combine that variable with all variables from, and sending all to for processing... in essence, carrying over variables from many
pages and lumping them all together into the last page.

Is there a way to place it into the input stream when using POST... or
should I use GET and then how and where to place it into the QUERY_STRING?

Non-working example:
print '<input type="text" size="10" name="var1">'
print "<P><INPUT type='submit' value='Submit'></P>"
form = cgi.FieldStorage()
VAR1 = form["var1"].value
#some database stuff happens
print '<input type="hidden" name=VAR1>'   # this doesn't seds a
literal string of VAR1 and not the variable
print '<P><input type="text" size="10" name="TEXT1"></P>
print "<P><INPUT type='submit' value='Submit'></P>"
print "</FORM>"
form = cgi.FieldStorage()
# print all enviromental variables
for key in os.environ.keys():
        print key + os.environ[key] + '<br>'
print form["VAR1"].value
print form["TEST1"].value

Shane Anglin
shanenaglin at

More information about the Python-list mailing list