title: Python - How do i know when a form button was pressed? (logout)
body: <p>I'm trying to make a logout button for my website in python CGI. I was wondering how would I know when the button was pressed?</p>
  
  <p>My logout form is as follows:</p>
  
  <pre><code>&lt;form id="logout" method="POST" action=""&gt;
     &lt;input type="submit" name="logout" value="Logout"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>From here, i know that I need to store the form in FieldStorage so I did the following:</p>
  
  <pre><code>form = cgi.FieldStorage()
  </code></pre>
  
  <p>I've tried doing an if statement such as: </p>
  
  <pre><code>if form.has_key('logout'):
      doLogoutFunction()
  </code></pre>
  
  <p>but it doesn't work. Please help</p>