WordPress forms submissions and PHP files

Have you try with admin-post.php for your form submission. admin_post hook available in WordPress gives you great control over the flow of execution for your form.

Using the above form, the following HTML content would execute the above hook when the user clicks either Submit.

<form action="http://www.example.com/wp-admin/admin-post.php" method="post">
  <input type="hidden" name="action" value="custom_form">
  <input type="hidden" name="data" value="formid">
    Name: <input type="text" name="user_name"/>
    Last Name: <input  type="text" name="user_last_name"/>
  <input type="submit" value="Submit">
</form>

Then, create a request or form handler for an “custom_form” action request, you would create a hook like this either in our theme function or plugin file.

add_action( 'admin_post_custom_form', 'my_custom_form_handler' );

function my_custm_form_handler() {
    // Handle request and process the form
}

For more info visit

Note: you can also use nonce & sanitize form field for more secure & validation.