How to Maintain url on form submit

If your form is embedded in a shortcode or some other front end form, I would post to the permalink for the page. That’s more reliable than using action=”” in my experience. Then output something on that page to acknowledge the submission or show an error.

$global $post;
printf('<form method="post" action="%s">',get_permalink($post->ID));

or in for a form on the admin side:

printf('<form method="post" action="%s">',admin_url('admin.php?page=custom_form'));

Within admin_url, include the portion of the page url that comes after wp-admin/