title: simple openID in php
body: <p>I'm using LightOpenID, and whilst it's very light, it's not very easy to understand, and it doesn't have a wiki...</p>
  
  <p>The example file they do give is below (sorry for the elongated post), what I don't understand is why does it instantiate the LightOpenID twice?</p>
  
  <pre><code>require 'openid.php';
  try {
  
      if(!isset($_GET['openid_mode'])) {  // what is this about?
  
          if(isset($_POST['openid_identifier'])) {
  
              $openid = new LightOpenID;
  
              $openid-&gt;identity = $_POST['openid_identifier'];
  
              header('Location: ' . $openid-&gt;authUrl());
          }
  ?&gt;
  &lt;form action="" method="post"&gt;
      OpenID: &lt;input type="text" name="openid_identifier" /&gt; &lt;button&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  &lt;?php
      } elseif($_GET['openid_mode'] == 'cancel') {
          echo 'User has canceled authentication!';
      } else {
          $openid = new LightOpenID;
          echo 'User ' . ($openid-&gt;validate() ? $openid-&gt;identity . ' has ' : 'has not ') . 'logged in.';
  
      }
  } catch(ErrorException $e) {
      echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>I'm trying to add it to my existing script <a href="http://pastie.org/1280030" rel="nofollow">here</a> if someone is really feeling helpful.
  How can I make it so that when $openid->validate() returns true, I can save the $sql_answer to the database?</p>