call php file from form and use wp functions

WordPress provides wp-admin/admin-post.php endpoint to work with form submissions.

You should likely point your form to it, add an identifying action, and use hooks in the file to process submission.