I am trying to process HTML form input. I have a CGI file that I want to collect all the data from, including the check boxes and radio buttons. I am trying to use cgi.FieldStorage but something is not working.
Here is an example of what I am trying to do:
form = cgi.FieldStorage()
name = form.getvalue('sensitivity')
print name
But this is returning none. Here is a snippet of the CGI file:
if config_settings.settings[5] == '1':
print'''<html><label class="checkbox inline control-label"><input name="aWeight" value="1" type="checkbox" checked/></html>'''
else:
print'''<html><label class="checkbox inline control-label"><input name="aWeight" value="1" type="checkbox"/></html>'''
print'''<html><span> A-Weight </span></label></html>'''
This sets a checkbox depending on the content of an XML tag in another file being set to 1 or 0. The XML file and the Python file are working together fine. What I am trying to acheive is to collect the data from the checkboxes when a user changes them.
I have the this code at the beginning of my CGI script:
<form class="well form-inline" method="post" action="/cgi-bin/process_setup.py">
And I though that this would allow me to process/collect the from data with cgi.FieldStorage but it does not seem to be working. Any advice?