Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Location
    Copenhagen
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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" ) ;

    ---------------------------------------------------------------------

  • #2
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •