I'm recieving data from a POST, Now I want to forward this data using curl.
The problem is that my code doesn't post special characters like ÅÄÖ. They are included in $postdata, but when I look at the receiving server, the special characters are missing.
Is there a better way to prepare the data for cUrl? Something like an prebuilt funktion? How do I include the ÅÄÖ:s?
Here is the code:
foreach ($_POST as $var => $value) {
if ($var != "ignore") {
$postdata=$postdata . urlencode(str_replace("_", "." , $var)) . "=" . $value . "&";
}
}
//remove the extra comma
$postdata=substr($postdata,0,-1);
//Submit the form fields
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$googleformURL);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$data = curl_exec ($ch);
curl_close($ch);