CGI handler: Retrieving POST and GET at the same time

S

Samuel

Hi,

I have the following form:

<form action="?one=1" method="post">
<input type="hidden" name="two" value="2" />
</form>

and would like to retrieve both fields, "one" and "two". However, the
following does not work:

form_data = cgi.FieldStorage()
for key in form_data:
print key + ":", form_data[key].value

It prints out:
two: 2

How can I retrieve the GET variables in that context?

-Samuel
 
P

Pierre Quentel

Hi,

I have the following form:

<form action="?one=1" method="post">
<input type="hidden" name="two" value="2" />
</form>

and would like to retrieve both fields, "one" and "two". However, the
following does not work:

form_data = cgi.FieldStorage()
for key in form_data:
print key + ":", form_data[key].value

It prints out:
two: 2

How can I retrieve the GET variables in that context?

-Samuel

Hi,

The argument passed in the url of the "action" attribute can be
retrieved by :

os.environ["QUERY_STRING"]

To get the key-value dictionary :

cgi.parse_qs(os.environ["QUERY_STRING"])

Regards,
Pierre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top