[0T] Re: Simple python + html + from --> to python script

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Oct 25 00:38:27 CEST 2006


flit a écrit :
> Hello All,
> 
> I am trying to get information from a form and send it to a python
> script without success..
> Here is my objective:
> 
> User enters data in form --> form send variables to python script -->
> script runs and output result.

<OT topic="HTTP">
If the script has side-effects (adding/updating/deleting database 
records, writing files, etc), the script should not "output results", 
but redirect to another url where the user can see these results.

Else - if the script doesn't have side-effects (ie :a search form, ...), 
then the HTTP method should be "GET", not "POST".
</OT>

> the form code
> 
> <form method="post" action="/cgi-bin/script.py" name="coord">Entre com
> os dados <input name="data1"><br>
> 
> Entre com os dados <input name="data2"><br>
> Vai magraum <button name="submete"></button></form>

<OT topic="HTML">
button elements don't submit the form - they in fact don't do anything 
unless you attach behaviour to them with javascript. What you want here 
is an input type='submit'.

Also, the "button" tag doesn't require a end tag.

<form method="POST" action="/cgi-bin/script.py" name="coord">
<label for="data1">Entre com os dados</label>
<input type="text" name="data1" id="data1"><br>

<label for="data2">Entre com os dados </label>
<input type="text" name="data2" id="data2"><br>
Vai magraum <input type="submit" name="submete">
</form>
</OT>

(cf Steve's answer and the cgi module's doc for your problem)



More information about the Python-list mailing list