Redirecting HTTP form post
The first statement I included worked properly but wasn't passing values that had multiple select options on my form. It was just populating "Array" in the fields. I corrected that by doing this:
$postParams = file_get_contents("php://input"); $ch = curl_init('http://mysite/capture.php');curl_setopt ($ch, CURLOPT_POST, 1);curl_setopt ($ch, CURLOPT_POSTFIELDS, $postParams);curl_exec ($ch);curl_close ($ch);
Then I needed the client to be redirected to a "Thank You" page, my backend program was sending this data, but I couldn't get cURL to function with it, I worked around this by doing a header refresh and setting the value to 1. Like so:
header("refresh:1;url=http://mythankyoupage");
Thanks for the help!
if im understanding you correctly, you are wanting to send post data?
try this:
$url = 'http://server.com/path';$data = array('key1' => 'value1', 'key2' => 'value2')// use key 'http' even if you send the request to https://...$options = array('http' => array( 'method' => 'POST', 'content' => http_build_query($data)));$context = stream_context_create($options);$result = file_get_contents($url, false, $context);
you dont have to build the $data array yourself, you can just pass on the $_POST array.