title: Sending POST data using cURL, by scanning QR code
body: <p>I'm trying to pass some data (<code>JSON</code>) to another page by scanning a QR code.
  The page where the data is send to, contains a <code>HTML</code> form. I want to use that form as a last chance to correct the data before sending it to the database.</p>
  
  <p>I found here at S.O. a way to pass the data using cURL: (<a href="https://stackoverflow.com/a/15643608/2131419">https://stackoverflow.com/a/15643608/2131419</a>)</p>
  
  <p>QR code library:
  <a href="http://phpqrcode.sourceforge.net" rel="nofollow noreferrer">http://phpqrcode.sourceforge.net</a></p>
  
  <p>I use the QR code execute this function:</p>
  
  <pre><code>function passData () {
      $url = 'check.php';
      $data = array('name' =&gt; 'John', 'surname' =&gt; 'Doe');
      $ch = curl_init( $url );
  
      # Setup request to send json via POST.
      $payload = json_encode($data);
      curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
      curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
  
      # Return response instead of printing.
      curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  
      # Send request.
      $result = curl_exec($ch);
      curl_exec($ch);
      curl_close($ch);
  
      # Print response.
      return $result;
  }
  </code></pre>
  
  <h2>Create QR code:</h2> 
  
  <pre><code>QRcode::png(passData(), $tempDir.'007_4.png', QR_ECLEVEL_L, 4);
  echo '&lt;img src="'.$tempDir.'007_4.png" /&gt;';
  </code></pre>
  
  <h2>Check.php</h2>
  
  <pre><code>&lt;?php $data = json_decode(file_get_contents("php://input"), true); ?&gt;
  
  &lt;form method="post" action="handle.php"&gt;
      &lt;input type="text" name="name" value="&lt;?php echo $data['name'];?&gt;" /&gt;&lt;br /&gt;
      &lt;input type="text" name="surname" value="&lt;?php echo $data['surname'];?&gt;" /&gt;&lt;br /&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <h2>Problem:</h2>
  
  <p>I can pass the data to check.php, but it's returning plain text instead of a useable <code>HTML</code> form.</p>
  
  <p><a href="https://i.stack.imgur.com/PUuFv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PUuFv.png" alt="enter image description here"></a></p>
  
  <p>Hope someone can help!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p><strong>Some clarification:</strong></p>
  
  <p>What I actually want is, to scan the QR code, which executes the passData() function. Then the 'QR code scanner app', needs to open a browser, which shows <code>check.php</code> with the form <strong>AND</strong> the passed data as the <code>values</code> of the <code>input</code> fields.</p>
  
  <p>Now, I get only the response of <code>check.php</code> (plain text).
  When I pass an <code>URL</code> instead of the <code>passData()</code> function like:<br />
  <code>QRcode::png("http://www.google.com", $tempDir.'007_4.png', QR_ECLEVEL_L, 4);</code></p>
  
  <p>The app asks if I want to go to <a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a>.</p>