title: PayPal IPN Won't Execute Certain Part(s) of Code
body: <p>I'm trying to work with with the PayPal IPN system. I have setup my code to use their SandBox platform for testing. I am looking for a reason as to why the <code>if (strcmp ($res, "VERIFIED") == 0) {</code> parts of my code is NOT executing. Not only that, but none of the part of this code are writing any output to "log.txt".</p>
  
  <p>I would appreciate a review of my code to let me know where I am going wrong.</p>
  
  <pre><code>&lt;?php
  require_once('includes/mysql.inc.php');
  
  if($_POST) {
      $req = 'cmd=' . urlencode('_notify-validate');
      foreach ($_POST as $key =&gt; $value) {
          $value = urlencode(stripslashes($value));
          $req .= "&amp;$key=$value";
      }
  
      // post back to PayPal system to validate
      $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
      $header .= "Host: sandbox.paypal.com\r\n";
      $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
      $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
      $fp = fsockopen ('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30);
  
      if (!$fp) {
          file_put_contents('log.txt', 'httperrrrr');
          die();
      } else {
          file_put_contents('log.txt', 'die here');
          fputs ($fp, $header . $req);
          while (!feof($fp)) {
              $res = fgets ($fp, 1024);
              $data = print_r($res, TRUE);
              if (strcmp ($res, "VERIFIED") == 0) {
                  file_put_contents('log.txt', 'verified');
                  $username = $_POST['custom'];
                  require_once('classes/admin.class.php');
                  $activate = new Admin($db);
                  $activate-&gt;modifyUser($username, 'activate');
              } else {
                  file_put_contents('log.txt', 'noverifyshit');
              }
          }
      } else {
          file_put_contents('log.txt', 'no post');
      }
  }
  ?&gt;
  </code></pre>