Insert Data into Database

You can handle that with sending the form to the script admin-post.php with that in the form :

<form method="POST" action="<?php echo admin_url("admin-post.php");?>?action=myPlugin__save_datas">

after that, you use this hook for the PHP treatment

add_action("admin_init", function () {

    if (    !isset($_POST["action"])
        ||  ("myPlugin__save_datas" !== $_POST["action"])
    ) {
        return;
    }


    // save datas
    // ...


    // redirection

    $url = home_url("https://wordpress.stackexchange.com/");

    wp_redirect($url);
    exit();

});

If you want just send form on connected or unconnected user, you have respectively the actions admin_post_myPlugin__save_datas and admin_post_nopriv_myPlugin__save_datas