I cant get parameters from URL. After reading numerous posts on the web but nothing seems to answer my question...
I have a simple HTML file:
<html>
<head>
</head>
<body>
<form action="test.py" method="get">
Name: <input id="person_name" type="text" name="person_name" >
<input id="submit_button" type="submit" value="Submit" >
</form>
</body>
and my python script looks like this:
import cgi, cgitb
form = cgi.FieldStorage()
name = str( form.getvalue('person_name') )
print ("Content-type:text/html\n\n")
print ("<html>")
print ("<head>")
print ("</head>")
print ("<body>")
print ("Hello " + name )
print("<br/>")
print ("all params: " + str(form) )
print ("</body>")
print ("</html>")
However, when I execute the HTML file and type "Mike" as a name, my python script prints:
Hello None
all params: FieldStorage(None, None, [])
the cgi.FieldStorage() is empty. How can I fix it?
It's hard to say.
<form action="test.py" method="get">
Error?It should be
<form action="cgi-bin/test.py" method="get">
If "cgi-bin" is not a part of the url sgi scripts are not executed. It's even surprising that you get some kind of response.