Echo Function in a PHP Mail Form

Hi, I’m trying to learn what all the variables in PHP mean, and how they make a website function. I read the PHP Mail form turtorial on the site, and integrated it into my site, and that part is working great (receiving form submissions, etc).
The only problem I’m having is in what happens once you click submit.
Currently, once you click submit it takes you from the page to the text that is in the echo function (i.e. “Thanks for submitting your information”)
I really would like to know how I can manipulate the PHP form so that when someone clicks submit, it still sends the information, but stays on the same page.
Any ideas?
Thanks!!!

Here is the what the code looks like, btw:

<?php
if(isset($_POST['submit'])) {

    $to = "emailaddress@gmail.com"; 
    $subject = "Subject";
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];

    foreach($_POST['check'] as $value) {
        $check_msg .= "Checked: $value
";
    }
    
    $body = "From: $name_field
 E-Mail: $email_field
";

    echo "Data has been submitted to $to!";
    mail($to, $subject, $body);
    
} else {
    echo "try again!";
}
?>