everything works in preview mode but not in published site

This is an old post from 2017 and being closed.
Please add a new forum post and refer back to this post with a link if needed.
For datasets make sure that you are using the right mode and permissions as shown here.
https://support.wix.com/en/article/about-collection-permissions
https://support.wix.com/en/article/working-with-dataset-modes-and-collection-permissions
So don’t use site content when you are using a user input form submission…
https://support.wix.com/en/article/creating-a-form-with-user-input-elements

Also, in editor and preview you are working in sandbox mode, whereas in your published site you are working in the live mode, so you need to make sure that your datasets are synced.
https://support.wix.com/en/article/syncing-data-between-sandbox-and-live-database-collections