views:

1445

answers:

2

Just started playing with Google App Engine & Python (as an excuse ;)). How do I correctly submit a form like this

<form action="https://www.moneybookers.com/app/payment.pl" method="post" target="_blank">
<input type="hidden" name="pay_to_email" value="[email protected]">
<input type="hidden" name="status_url"
<!-- etc. -->
<input type="submit" value="Pay!">
</form>

w/o exposing the data to user?

A: 

By hiding the sensitive bits of the form and submitting it via JavaScript.

Make sure you have a good way of referring to the form element...

<form ... id="moneybookersForm">...</form>

... and on page load, execute something like

document.getElementById("moneybookersForm").submit();

At least I don't know of other ways. For JavaScript-disabled people, the Pay! button should be kept visible.

AKX
He's asking for a solution in Python, not in Javascript.
Evan Fosmark
I was just guessing this was what he wanted. As far as I know, there's no way of submitting a form in server-side Python and still let the user-agent see the resulting page.
AKX
No, but you can forward the result on to the client.
Jason Baker
+4  A: 

It sounds like you're looking for urllib.

Here's an example of POSTing from the library's docs:

>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
>>> print f.read()
Jason Baker