Fortunately, all this can be done from within the WordPress admin so you don’t need any code snippets to make this work.
First up, create your form and be sure to enable the create entries setting under Form Settings > Entries.
Next, create a field group for your form fields and in the Location settings you want to have the following rules set up:
This combination of rules allows the Advanced Forms plugin to map the field group to your form while also allowing the ACF Custom Database Tables plugin to map the field group to a database table.
In the ACF Custom Database Tables Settings box, enable the Manage Table Definition setting and specify your table name.
From this point, you just need to go through the normal table creation/update process and you’ll then have your form entry data storing to your custom table.