Question using CGI in Python

Maan M. Hamze mmhamze at pleiades.net
Tue Aug 28 16:55:19 EDT 2001


"Maan M. Hamze" <mmhamze at pleiades.net> wrote in message
news:too0t8tc1k3c8c at corp.supernews.com...
>
> "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
or of course you can use:
print '<input type="hidden" name=',VAR1,'>'
As you see, you should not include your variable in the string because it
will be treated just like another string.
> Maan
>
>
>





More information about the Python-list mailing list