title: Button To Perform 2 Actions VIA PHP POST
body: <p>I have this PHP script that performs two functions:</p>
  
  <ol>
  <li>Increases the count in an XML tag of prayer_warriors by 1.</li>
  <li>Sends a push notification to the proper user.</li>
  </ol>
  
  <p>In my app, I can POST, and all the functions of the script get carried out.  The script code is:</p>
  
  <pre><code>&lt;?php
  $first_name = $_POST['first_name'];
   $last_name = $_POST['last_name'];
   $title = $_POST['title'];
   $deviceToken = $_POST['iostoken'];
  $xml = simplexml_load_file("/Test.xml") or die("Not loaded!\n");
  
  
  $responses = $xml-&gt;xpath("//channel/item[title = '$title' and first_name = '$first_name' and last_name = '$last_name']/prayer_warriors");
  $responses[0][0] = $responses[0] + 1;
  echo($responses);
  $xml-&gt;asXML("Test.xml");  
  // Put your device token here (without spaces):
  
  // Put your private key's passphrase here:
  $passphrase = 'Passphrase';
  
  // Put your alert message here:
  $message = 'Someone just pledged to pray for you!';
  
  ////////////////////////////////////////////////////////////////////////////////
  
  $ctx = stream_context_create();
  stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
  stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
  
  // Open a connection to the APNS server
  $fp = stream_socket_client(
      'ssl://gateway.push.apple.com:2195', $err,
      $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
  
  if (!$fp)
      exit("Failed to connect: $err $errstr" . PHP_EOL);
  
  echo 'Connected to APNS' . PHP_EOL;
  
  // Create the payload body
  $body['aps'] = array(
      'alert' =&gt; $message,
      'sound' =&gt; 'default'
      );
  
  // Encode the payload as JSON
  $payload = json_encode($body);
  
  // Build the binary notification
  $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
  
  // Send it to the server
  $result = fwrite($fp, $msg, strlen($msg));
  
  if (!$result)
      echo 'Message not delivered' . PHP_EOL;
  else
      echo 'Message successfully delivered' . PHP_EOL;
  
  // Close the connection to the server
  fclose($fp);  
  ?&gt;
  </code></pre>
  
  <p>I use the following to POST to this PHP from a web page.  It will trigger the part to send a push notification, but will NOT increase the prayer_warrior count by 1.</p>
  
  <pre><code>$title = $item-&gt;title;
  $first_name = $item-&gt;first_name;
  $last_name = $item-&gt;last_name;
  $iostoken = $item-&gt;iostoken;
  Echo "&lt;form action=\"http://Url.php\" method=\"post\"&gt;";
  Echo "&lt;input type=\"hidden\" name=\"first_name\" value=".$first_name."&gt;";
  Echo "&lt;input type=\"hidden\" name=\"last_name\" value=".$last_name."&gt;";
  Echo "&lt;input type=\"hidden\" name=\"title\" value=".$title."&gt;";
  Echo "&lt;input type=\"hidden\" name=\"iostoken\" value=".$iostoken."&gt;";
  
   Echo  "&lt;input type=\"submit\" name=\"submit\" value=\"Pledge to pray\" /&gt;";
  Echo "&lt;/form&gt;";
  </code></pre>
  
  <p>Any ideas why it would do this?</p>