I have an initial page which contains a html form which transfers data to post.php
to then Curl it.
Problem: I am transferring the data to a url however, when you click submit from the html page, the url structure then takes you to the following http://localhost:8888/post.php
and it brings in all the html back and places it within the post.php.
However, i want it to follow to the external URL but all i get back is a header response which contains the relative URL. I have tried CURLOPT_FOLLOWLOCATION
and still nothing.
HTML:
<form name="nonjava" method="post" action="/post.php">
<input name="postdata" id="nonjavapostdata" type="hidden" value="<?php echo $variables['postdata']; ?>" />
<label for="amount1" class="">£</label>
<input required="" type="text" class="" id="amount1" name="amount1">
<input required="" type="text" class="" id="amount2" name="amount2">
<label for="amount2" class="">P</label>
<button type="submit" class="btn btn-default" href="">Submit</button>
</form>
Now with this data, i am transferring everything over to the post.php
and determining all the $_POST
and curling it to an external URL as a HTTP header.
PHP:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'postdata=' . urlencode(xmlTransfer()));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
// curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_VERBOSE, true);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);