title: Facebook PHP SDK not allowing to login a user
body: <p>All,
  I'm using wordpress and trying to have my user login with facebook. In my header.php for Wordpress I have the following code:</p>
  
  <pre><code>define('123', '123');
  
  //uses the PHP SDK.  Download from https://github.com/facebook/php-sdk
  require 'facebook.php';
  
  $facebook = new Facebook(array(
    'appId'  =&gt; '123',
    'secret' =&gt; '12345',
    'cookie' =&gt; true,
  ));
  
  $uid = $facebook-&gt;getUser();
  if ($uid) {
      try {
          $userInfo = $facebook-&gt;api('/' + $uid);
          $qry = "Select user_id, role from event_details where email_address='$userInfo[email]'";
          echo $qry;
          $result = mysql_query($qry);
          $resultrows = mysql_num_rows($result);
          if($resultrows&gt;0){
              $resultset = mysql_fetch_array($result);
              $_SESSION['user_id'] = $resultset['user_id'];
              $_SESSION['role'] = $resultset['role'];
              $target = "http://www.website.com/event_choices";
              header("Location:". $target);
          }
      } catch (FacebookApiException $e) {
          error_log($e);
      }
  }else{
      echo "not logged into facebook";
  }
  
  if ($uid) {
      $logoutUrl = $facebook-&gt;getLogoutUrl();
  } else {
      $loginUrl = $facebook-&gt;getLoginUrl(array(
      'next'=&gt;'http://www.website.com/event_choices'
      ));
  }
  </code></pre>
  
  <p>Then when I'm creating a page actually in Wordpress I have the following code:</p>
  
  <pre><code>&lt;?php if ($uid): ?&gt;
  &lt;?php echo "Welcome, ".$uid['first_name']. ".&lt;br /&gt;"; ?&gt;
  &lt;a href="&lt;?php echo $logoutUrl; ?&gt;"&gt;
    &lt;img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif"&gt;
  &lt;/a&gt;
  &lt;?php else: ?&gt;
    &lt;a href="&lt;?php echo $loginUrl; ?&gt;"&gt;
      &lt;img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif"&gt;
    &lt;/a&gt;
  &lt;?php endif ?&gt;
  </code></pre>
  
  <p>This displays the login button but whenever I click on the button nothing happens. When I look at the source code the $loginUrl isn't being populated. What am I doing wrong?</p>
  
  <p>Thanks!</p>