title: How to use curl return value in php script
body: <p>I have two servers: A where WP is installed on one, and B where it's not. Application run on B is trying to use WP credentials for login. I have a login form on server B:</p>
  
  <pre><code>&lt;h1&gt;Login&lt;/h1&gt;
  &lt;div&gt;
  &lt;form class="forma" id="form" 
      action="login.php" method="POST"&gt;
    &lt;div class="form-group"&gt;
      &lt;label&gt;Username&lt;/label&gt;
          &lt;input class="form-control" type="text" name="username" /&gt;
          &lt;label&gt;Password&lt;/label&gt;
          &lt;input class="form-control" type="text" name="password" /&gt;
    &lt;/div&gt;
    &lt;button class="submit btn btn-success" type="submit" name="login" value="Login"&gt;Login&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;/div&gt;
  &lt;?php
  if (isset($_POST["login"])) {
      $params = array('username' =&gt; $_POST["username"], 'password' =&gt; $_POST["password"]);
  
  $url = 'http://xxx/custom_login.php?' . http_build_query($params);
  $curl_handle=curl_init();
      curl_setopt($curl_handle, CURLOPT_URL,$url);
      curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
      curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl_handle, CURLOPT_NOBODY, false);
      $query = curl_exec($curl_handle);
      curl_close($curl_handle);
  
      if ($query==1) {
          $_SESSION['loggedin'] = true;
          header ("location: index.php");
      }
      else {
          echo "error";
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>Now, on server A, there is a custom_login.php script:</p>
  
  <pre><code>&lt;?php 
      require('wp-blog-header.php'); 
  ?&gt;
  
  &lt;?php
  
  $uid=$_GET["username"];
  $pwd=$_GET["password"];
  
  $user = wp_authenticate( $uid, $pwd );
  
  if ( is_wp_error( $user ) ) {
      return 0;
  }
  else {
      return 1;
  }
  
  ?&gt;
  </code></pre>
  
  <p>No matter what I try to type, I don't get logged in, meaning my $query never gets to be 1. How do I get the return value with curl? Because this is clearly not working.</p>