PHP Form Builder Class / Examples / Google Spreadsheets

Version: Released:

Google Spreadsheets - This project's sendToGoogleSpreadsheet function provides the ability to send a form's submitted data direclty to a Google Docs spreadsheet using the Google Spreadsheet API. This function has four parameters as seen below.

Before getting started, you'll want to review the checklist of information provided below to ensure you have a good understanding on how this functionality works.

  1. You'll need a Google account. If you don't have one, you can create one by clicking the "Create an account now" link at http://docs.google.com.
  2. If the spreadsheet title you specify in the sendToGoogleSpreadsheet function does not exist, a new spreadsheet will be created for you with the appropriate title and column headers.
  3. If you're creating your spreadsheet manually through the Google Docs GUI, an important thing to keep in mind is that Google will treat the initial row of cells as column identifiers. These column identifiers must match an element's label used in your form ("First Name:", "Last Name:", etc), which enables the form's submitted data to be correctly placed within the appropriate column. If the spreadsheet you specify in the sendToGoogleSpreadsheet function exists but has no inital row of column headers, your form's data will not populated upon submission. Your spreadsheet does not need to contain a column for every element used in the form - data for those elements that are not included will just not be collected. Likewise, your spreadsheet can contain column identifiers that don't match an element's label used in the form - data for those columns will be left blank.
  4. Elements of type hidden, captcha, button, html, and htmlexternal will not be included in the information that is sent to your Google spreadsheet.
  5. The "ignoreGSSend" element attribute can be applied to form elements that you do not want to be send to your Google Docs spreadsheet. The hidden field "cmd" has this attribute set in the form below.
  6. If you're populating an existing spreadsheet in your Google Docs account, you can store the web server's date/time at the moment the form's data is submitted by adding "Timestamp" as a column header.

In the php source code of this example file, you'll see that the sendToGoogleSpreadsheet function call currently contains demo authentication/spreadshet settings ("my_email", "my_password", etc). You'll want to replace these with your information.

Processing