How to send Website Data to Google Sheet (Without API)
By Webotapp Academy•Published: •Updated:
In this article we will learn how to send website data to google sheet in the most simplest way.
Step 1: Create a Google Form
- Create a new Google Form.
- Add fields that you want to populate from your PHP script. For example, let's say you have two fields: "Name" and "Email".
Step 2: Get Form URL and Field IDs
- Once your form is ready, click on the three dots in the upper-right corner and choose "Get pre-filled link".
- Fill in some sample data and click "Get Link".
- The generated link will have the field IDs you need. It will look something like this:
https://docs.google.com/forms/d/e/[FORM_ID]/formResponse?entry.[FIELD_ID_1]=sampleName&entry.[FIELD_ID_2]=sampleEmail
Step 3: PHP Code
Here's a simple PHP code snippet to send data to Google Sheets using cURL:
'John',
'entry.[FIELD_ID_2]' => 'john@example.com'
];
// Initialize cURL
$ch = curl_init();
// cURL settings
curl_setopt($ch, CURLOPT_URL, $formUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL
$result = curl_exec($ch);
// Close cURL
curl_close($ch);
// Output the result (for debugging)
echo $result;
?>
Replace [FORM_ID], [FIELD_ID_1], and [FIELD_ID_2] with your actual Form ID and Field IDs.
Full Source Code is Written Below
Google.php Page
"$name",
'entry.547919694' => "$mobile",
'entry.981977111' => "$email"
];
// Initialize cURL
$ch = curl_init();
// cURL settings
curl_setopt($ch, CURLOPT_URL, $formUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL
$result = curl_exec($ch);
// Close cURL
curl_close($ch);
// Output the result (for debugging)
//echo $result;
header("Location: thankyou.php");
}
?>
Simple Form
Thankyou.php Page
Thank you
Thank you
Exclusive Discount Offer
Inquire for Course Fee & Discounts
Get full program details, syllabus breakdown, and claim your exclusive course fee discount for the Best Digital Marketing Course in Guwahati.