How to send Website Data to Google Sheet (Without API)
By Webotapp Academy•
<!-- wp:paragraph -->\n<p>In this article we will learn how to send website data to google sheet in the most simplest way.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3 class=\"wp-block-heading\">Step 1: Create a Google Form</h3>\n<!-- /wp:heading -->\n\n<!-- wp:list {\"ordered\":true} -->\n<ol><!-- wp:list-item -->\n<li>Create a new Google Form.</li>\n<!-- /wp:list-item -->\n\n<!-- wp:list-item -->\n<li>Add fields that you want to populate from your PHP script. For example, let's say you have two fields: \"Name\" and \"Email\".</li>\n<!-- /wp:list-item --></ol>\n<!-- /wp:list -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3 class=\"wp-block-heading\">Step 2: Get Form URL and Field IDs</h3>\n<!-- /wp:heading -->\n\n<!-- wp:list {\"ordered\":true} -->\n<ol><!-- wp:list-item -->\n<li>Once your form is ready, click on the three dots in the upper-right corner and choose \"Get pre-filled link\".</li>\n<!-- /wp:list-item -->\n\n<!-- wp:list-item -->\n<li>Fill in some sample data and click \"Get Link\".</li>\n<!-- /wp:list-item -->\n\n<!-- wp:list-item -->\n<li>The generated link will have the field IDs you need. It will look something like this: <code>https://docs.google.com/forms/d/e/[FORM_ID]/formResponse?entry.[FIELD_ID_1]=sampleName&entry.[FIELD_ID_2]=sampleEmail</code></li>\n<!-- /wp:list-item --></ol>\n<!-- /wp:list -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3 class=\"wp-block-heading\">Step 3: PHP Code</h3>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Here's a simple PHP code snippet to send data to Google Sheets using cURL:</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code><?php\n// Google Form URL\n$formUrl = 'https://docs.google.com/forms/d/e/[FORM_ID]/formResponse';\n\n// Data to be sent\n$data = [\n 'entry.[FIELD_ID_1]' => 'John',\n 'entry.[FIELD_ID_2]' => 'john@example.com'\n];\n\n// Initialize cURL\n$ch = curl_init();\n\n// cURL settings\ncurl_setopt($ch, CURLOPT_URL, $formUrl);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $data);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n\n// Execute cURL\n$result = curl_exec($ch);\n\n// Close cURL\ncurl_close($ch);\n\n// Output the result (for debugging)\necho $result;\n?></code></pre>\n<!-- /wp:code -->\n\n<!-- wp:paragraph -->\n<p>Replace <code>[FORM_ID]</code>, <code>[FIELD_ID_1]</code>, and <code>[FIELD_ID_2]</code> with your actual Form ID and Field IDs.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Full Source Code is Written Below</strong></p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Google.php Page</strong></p>\n<!-- /wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code><?php\n\n$name = $_POST['name'];\n$mobile = $_POST['mobile'];\n$email = $_POST['email'];\n\n\nif (isset($_POST['submit'])) {\n // Google Form URL\n$formUrl = 'https://docs.google.com/forms/d/e/1FAIpQLSfFOl9BfdtdVHf_hcqe69ZwLKQ6GHWSeDJPaFP9d-2v20FA_Q/formResponse';\n\n// Data to be sent\n$data = [\n 'entry.1027832668' => \"$name\",\n 'entry.547919694' => \"$mobile\",\n 'entry.981977111' => \"$email\"\n];\n\n// Initialize cURL\n$ch = curl_init();\n\n// cURL settings\ncurl_setopt($ch, CURLOPT_URL, $formUrl);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $data);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n\n// Execute cURL\n$result = curl_exec($ch);\n\n// Close cURL\ncurl_close($ch);\n\n// Output the result (for debugging)\n//echo $result;\n\nheader(\"Location: thankyou.php\");\n}\n?>\n\n\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>Simple Form</title>\n</head>\n<body>\n\n <form method=\"POST\">\n <input type=\"text\" name=\"name\">\n <br>\n <input type=\"text\" name=\"email\">\n <br>\n <input type=\"text\" name=\"mobile\">\n <br>\n\n <button name=\"submit\">Submit form</button>\n </form>\n\n</body>\n</html></code></pre>\n<!-- /wp:code -->\n\n<!-- wp:paragraph -->\n<p>Thankyou.php Page</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code><!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>Thank you</title>\n</head>\n<body>\nThank you\n</body>\n</html></code></pre>\n<!-- /wp:code -->