Question using CGI in Python

Maan M. Hamze mmhamze at pleiades.net
Tue Aug 28 16:46:56 EDT 2001


"Shane Anglin" <shane.anglin at mtni.net> wrote in message
news:mailman.999027702.15146.python-list at python.org...
>
Shane
I see what you want to do.  Try this:

> Non-working example:
> --app1.py:
> print "<FORM METHOD='POST' ACTION='app2.py'>
> print '<input type="text" size="10" name="var1">'
> print "<P><INPUT type='submit' value='Submit'></P>"
> </FORM>
> #SUBMIT
>
> --app2.py:
> form = cgi.FieldStorage()
> VAR1 = form["var1"].value

Now, we have to 'build' the hidden input!
Hidden = '<input type=hidden name=' + VAR1 + '>'

> #some database stuff happens
> print "<FORM METHOD='POST' ACTION='app3.py'>

Now use :
print Hidden
instead of:
> print '<input type="hidden" name=VAR1>'   # this doesn't work..it seds a
> literal string of VAR1 and not the variable
Maan






More information about the Python-list mailing list