I am trying to get user-inputted data from a web page generated in one Python script to submit to another Python script to process that data. In the first python script I have used the following to create a web form to submit data:
print("<form action='newspeciescheck.py' method='post'>")
print("<p>Genus: <input type='text' name='newgenus'/> <p>Species: <input type='text' name='newspecies'/>")
print("<input type='submit' value='Enter'>")
print("</form>\n ")
In the target script I have
formfields = cgi.FieldStorage()
newgenus = formfields.getValue('newgenus')
newspecies = formfields.getValue('newspecies')
However, when I try to run this, cgitb throws an error telling me that:
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
C:\Abyss Web Server\htdocs\pyscripts\newspeciescheck.py in ()
21
22 formfields = cgi.FieldStorage()
=> 23 newgenus = formfields.getValue('newgenus')
24 status=''
25 if newgenus==None:
newgenus undefined, formfields = FieldStorage(None, None, [MiniFieldStorage('newg...phis'), MiniFieldStorage('newspecies', 'fabae')]), formfields.getValue undefined
C:\Users\John\AppData\Local\Programs\Python\Python36\lib\cgi.py in __getattr__(self=FieldStorage(None, None, [MiniFieldStorage('newg...phis'), MiniFieldStorage('newspecies', 'fabae')]), name='getValue')
583 def __getattr__(self, name):
584 if name != 'value':
=> 585 raise AttributeError(name)
586 if self.file:
587 self.file.seek(0)
builtin AttributeError = <class 'AttributeError'>, name = 'getValue'
AttributeError: getValue
args = ('getValue',)
with_traceback = <built-in method with_traceback of AttributeError object>
So why do my submitted values end up in MiniFieldStorage rather than normal FieldStorage? More importantly how do I get them to end up as normal FieldStorage?