<?php // Zend library include path set_include_path(get_include_path() . PATH_SEPARATOR . "{$_SERVER['DOCUMENT_ROOT']}/ZendGdata-1.8.1/library"); include_once "Google_Spreadsheet.php"; include_once "../../../config/post_spreadsheet_config.php"; $ss = new Google_Spreadsheet($u, $p); $ss->useSpreadsheet("Mailing List 2015"); $name = Trim(stripslashes($_GET['name'])); $email = Trim(stripslashes($_GET['email'])); $year = Trim(stripslashes($_GET['year'])); $campus = Trim(stripslashes($_GET['campus'])); $interest = Trim(stripslashes($_GET['interest'])); $involvement = Trim(stripslashes($_GET['involvement'])); // if not setting worksheet, "Sheet1" is assumed // $ss->useWorksheet("worksheetName"); $row = array("Name" => $name, "Email" => $email, "Year of Study" => $year, "College/Campus" => $campus, "Area of interest" => $interest, "Involvement in TEDxUofT" => $involvement); if ($ss->addRow($row)) { echo "Form data successfully stored using Google Spreadsheet"; } else { echo "Error, unable to store spreadsheet data"; }
array_push($stage2, substr($stage, $i, 1) . "2"); } array_push($stage2, substr($stage, $len - 1, 1) . "1"); } #print_r($stage2); ## get or add row to Stages and write cells $subid = "CSP-" . $row['subprojectstatus']; $nrnb = $row['nrnbcontact']; $title = $row['projecttitle']; $uprow = array('projecttitle' => $title, 'nrnbcontact' => $nrnb, 'subprojectstatus' => $subid); foreach ($stage2 as $st) { $col = "st" . $st; $uprow[$col] = $st; } ## UPDATE GOOGLE DOC $rowcheck = $ss2->getRows("subprojectstatus=\"{$subid}\""); if ($rowcheck) { if ($ss2->updateRow($uprow, "subprojectstatus=\"{$subid}\"")) { echo "Data successfully updated for subproject ID: {$subid}\n"; } else { echo "Error, unable to update data for subproject ID: {$subid}\n"; } } else { if ($ss2->addRow($uprow)) { echo "Data successfully added for subproject ID: {$subid}\n"; } else { echo "Error, unable to add data for subproject ID: {$subid}\n"; } } } }
} if (!$mail->Send()) { $ret['error'] = 1; } } /**************** GOOGLE.DOCS method ************************/ if ($_SETTINGS['store_to_gdocs']) { include_once "GoogleSpreadsheet/Google_Spreadsheet.php"; $ss = new Google_Spreadsheet($_SETTINGS['gdocs']['user'], $_SETTINGS['gdocs']['password']); $ss->useSpreadsheet($_SETTINGS['gdocs']['spreadsheet_name']); $ss->useWorksheet($_SETTINGS['gdocs']['worksheet_name']); $row = array("Date" => date("m/d/Y H:i")); foreach ($_POST['fields'] as $k => $v) { $row[$k] = $v; } if (!$ss->addRow($row)) { $ret['error'] = 1; } } /**************** MailChimp method ************************/ if ($_SETTINGS['store_to_mailchimp']) { if (@$_POST['fields'][$_SETTINGS['email_field_name']] && $_SETTINGS['mailchimp']['apikey'] && $_SETTINGS['mailchimp']['listId']) { include_once 'mailChimp/MCAPI.class.php'; $MCAPI = new MCAPI($_SETTINGS['mailchimp']['apikey']); $arr = array('EMAIL' => $_POST['fields'][$_SETTINGS['email_field_name']]); if ($_SETTINGS['first_name_field_name']) { $arr['FNAME'] = @$_POST['fields'][$_SETTINGS['first_name_field_name']]; } if ($_SETTINGS['last_name_field_name']) { $arr['LNAME'] = @$_POST['fields'][$_SETTINGS['last_name_field_name']]; }