Processing form data with a Python CGI Script
<p>Can anyone point out where I am going wrong here. I have two scripts, one for the form and the other for the processing. It looks correct but after two hours of staring at it I cannot see where I am going wrong.
Here are the two scripts, they are very short so please take a look at it.</p>

<p>The Form:</p>

<pre><code>#!/usr/bin/python
import os
import cgi
import cgitb



print("Content-Type: text/html\n\n")
print("")

print'''&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
    &lt;title&gt;Marks Sonitus Practice&lt;/title&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;meta name="description" content="Practice"&gt;
    &lt;meta name="author" content="CGI Practice"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="process_data.py" method="post"&gt;
    &lt;html&gt;&lt;span&gt; First &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/label&gt;
    &lt;input type="text" name="firstname"/&gt;
    &lt;input type="submit" name ="submitname" value="Submit Name"&gt;&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;'''
</code></pre>

<p>The script to process the form:</p>

<pre><code>#!/usr/bin/python
import os
import cgi
import cgitb
cgitb.enable(display=0,logdir="/var/www/cgi-bin/error-logs")

file_name = "/var/www/cgi-bin/practice/process_practice.py"
f = os.path.abspath(os.path.join(file_name))
try:
    open(f)
except:
    print"This file could not be found!"
form = cgi.FieldStorage(f)
firstname = form.getvalue('firstname')
print firstname
</code></pre>

<p>Can anyone show me where I am going wrong with this?</p>