I have multiple forms in a html file, which all call the same python cgi script. For example:
<html>
<body>
<form method="POST" name="form1" action="script.cgi" enctype="multipart/data-form">
....
</form>
...
<form method="POST" name="form2" action="script.cgi" enctype="multipart/data-form">
...
</form>
...
</body>
</html>
And in my cgi script I do the following:
#!/usr/bin/python
import os
import cgi
print "content-type: text/html; charset=utf-8\n\n"
form = cgi.FieldStorate();
...
I am unable to get the data from the second from. I have tried to call FieldStorage multiple times, but that did not seem to work. So my question is how do I access different forms in the same cgi script?
You cannot. The browser submits one form, or the other, but not both.
If you need data from both forms, merge the forms into one <form>
tag instead.