Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-23-2012, 10:13 PM   PM User | #1
mariaklog
New to the CF scene

 
Join Date: Aug 2012
Location: Copenhagen
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mariaklog is an unknown quantity at this point
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" ) ;

---------------------------------------------------------------------
mariaklog is offline   Reply With Quote
Old 09-12-2012, 03:19 PM   PM User | #2
wan-0
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
wan-0 is an unknown quantity at this point
Hi mariaklog

I'm no expert. I've encountered the same trouble as you.
If you aim at submitting a customized google form as I do, give this simpler way a try : customizing and styling google forms.

Hope it helps
Regards
wan-0 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:19 PM.


Advertisement
Log in to turn off these ads.