|
Please help!!!! PHP Curl problem
Hi Experts,
I've spent over a week trying to solve this problem hopefully someone out there can spot the problem.
The form is submitted to a php file that includes some cURL script to do the submission to google.
No errors are returned and only the 1st field from the form arrives in the destination spreadsheet in google docs.
I'm here all so if you have a suggestion to try let me know and I'll respond ASAP.
I'm tempted to chuck this out the window but I don't want to give up on it.. it's a nice script. Thanks!
-------------------------------------------------------------------------
This is the cURL script:
/Google Form Key
$formkey = "dFdDTFBFRG1yZm9MckZUanFuM2dEd1E6MQ";
//Email address of person who should get email notification of form submission
$toemail = "username@ domain.com";
$thankyou = "http://www.jazzerup.com/blogexamples/googleform/thankyou.html";
//Change this URL to your google form address
$googleformURL = "https://spreadsheets.google.com/formResponse?formkey=$formkey";
//----------------Send Form Fields to Google--------------------
//Loops through the form fields and creates a query string to submit to google
foreach ($_POST as $var => $value) {
if ($var != "ignore") {
$postdata=$postdata . htmlentities(str_replace("_", "." , $var)) . "=" . $value . "&";
}
}
//remove the extra comma
$postdata=substr($postdata,0,-1);
//Submit the form fields to google
$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);
//echo $data;
//Redirect to your thank you page
header( "Location: $thankyou" ) ;
---------------------------------------------------------------------
|