title: Passing form variables to curl request
body: <p>Alright, so I'm trying to create a simple HTML page with a form to submit a pushbullet request using cURL.</p>
  
  <p>So far, my HTML looks like this.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Omran's Push Application&lt;/title&gt;
  &lt;link rel="stylesheet" href="css/style.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method="post" onSubmit="window.location='index.htm" action="post.php"&gt;
  &lt;p&gt;
  &lt;label for="login"&gt;From:&lt;/label&gt;
    &lt;input type="text" name="title" id="login"&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;label for="message"&gt;Message:&lt;/label&gt;
    &lt;input type="text" name="body" id="password"&gt;
  &lt;/p&gt;
  &lt;p class="login-submit"&gt;
    &lt;button type="submit" class="login-button"&gt;Login&lt;/button&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the following is the PHP/cURL side of things.</p>
  
  <pre><code>&lt;?php
  //create array of data to be posted
  $post_data['title'] = $_POST['title'];
  $post_data['body'] = $_POST['body'];
  //traverse array and prepare data for posting (key1=value1)
  foreach ( $post_data as $key =&gt; $value) {
  $post_items[] = $key . '=' . $value;
  }
  //create the final string to be posted using implode()
  $post_string = implode ('&amp;', $post_items);
  //create cURL connection
  $curl_connection = curl_init('https://api.pushbullet.com/v2/pushes');
  //set options
  curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($curl_connection, CURLOPT_HTTPHEADER, ['Access-Token: TOKEN_HERE']);
  curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
  //set data to be posted
  curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
  //perform our request
  $result = curl_exec($curl_connection);
  curl_close($curl_connection);
  ?&gt;
  </code></pre>
  
  <p>It's not giving though. It just gives a blank page at post.php</p>
  
  <p>Any ideas?</p>