The best way to use forms...

I have chosen not to use the Wix forms and have created my own which has a series of input boxes and a series of text boxes. I populate the text boxes based on the entries in the input boxes and this is all working well.

I have a submit button and the database is now populating. Unfortunately it is populating twice - once with values and once without. I only want the row in the database that has the values. If I remove the wixData.insert code I only get the line without data but if I remove the first block of code then toInsert isn’t defined. That’s my first challenge.

let toInsert = {
“firstName” : $w( ‘#name’ ).value,
“email” : $w( ‘#email’ ).value,
“phone” : $w( ‘#phone’ ).value,
“Sensors” : $w( ‘#sensors’ ).value,
“Additional Users” : $w( ‘#users’ ).value,
“Additional Data” : $w( ‘#additionalData’ ).value,
“Additional Actions” : $w( ‘#additionalActions’ ).value,
“Total Price” : totalPrice,
“Sensor Limit” : sensors,
“User Limit” : users + 4 ,
“Actions Limit” : (users + sensors + actions) * 10 ,
“Data Limits” : data + sensors

}

wixData.insert( "getAQuote02" , toInsert) 

The second challenge is that I now want to include some of the data in an email alert. I’ve set up the automation and that produces emails (two unless I remove the wixData code), but I can’t see how I can include the data in those emails. Is there a way of doing that?