Thanks for purchasing our Google Sheet Registration Form :)
It is our great pleasure that you purchased our tools.
If you have any questions, feel free to contact us at support@designcollection.in.
To change the credentials, open the login.php web page and change your username and password.
Start a new spreadsheet
Moving on, we now need to generate a Google Sheets app URL that will give us the ability to automatically send data to Google Sheets when we submit our PHP form.
We'll all get along don't worry!
1. We name our Google Spreadsheet “google-Sheet-form-data”. You can give a different name. whatever you'd like. I have named it “google-Sheet-form-data”. Just remember that we will need this name later.
2. We give our Google Sheets column the same name as our name attribute in the PHP form. Remember our first input field is named "email" and second one is named "phone" and third one is named "permanent_address" and there are many more..
3. Go to the Extension Tab in Google Sheets once the field names have been properly configured. Select the Apps Script function by clicking on it. You will be taken to a different page as a result..
4. In this Apps Script page, you will see a sample code of the JavaScript function.
5. We can now just copy and paste our JavaScript code. This is how the code looks:
var sheetName = 'Sheet1' var scriptProp = PropertiesService.getScriptProperties() function intialSetup () { var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet() scriptProp.setProperty('key', activeSpreadsheet.getId()) } function doPost (e) { var lock = LockService.getScriptLock() lock.tryLock(10000) try { var doc = SpreadsheetApp.openById(scriptProp.getProperty('key')) var sheet = doc.getSheetByName(sheetName) var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0] var nextRow = sheet.getLastRow() + 1 var newRow = headers.map(function(header) { return header === 'timestamp' ? new Date() : e.parameter[header] }) sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow]) return ContentService .createTextOutput(JSON.stringify({ 'result': 'success', 'row': nextRow })) .setMimeType(ContentService.MimeType.JSON) } catch (e) { return ContentService .createTextOutput(JSON.stringify({ 'result': 'error', 'error': e })) .setMimeType(ContentService.MimeType.JSON) } finally { lock.releaseLock() } }
Here our code after replacing
6. Next, we just run our Apps Script.
7. After running the script, Google will ask you to allow the script to run.
8. Execution log indicating the successful execution of your code
9. The next step in the PHP form submit for our Google Apps script is to Add a trigger and select the appropriate option for it. which are listed below:
10. Add Trigger for google-sheet-form-deta
11. Now that Apps Script has a trigger attached to it. Here, we select the newly available deployment option by clicking the Deploy button.
12. We must grant access to all when we publish the Apps Script. Select "Anyone" under the "who has access" option. However, you may be asked to grant access. Finally, your deployment URL will appear.
13. Now you have to share the link.
14. You have to paste the URL of Google Spreadsheet in demo-1.php, demo-2.php, demo-3.php, demo-4.php, demo-5.php.
If you have any questions, feel free to contact us at support@designcollection.in.