Stay on same page after form submit within WordPress


Staff member
I've added my HTML page as part of the admin wordpress (see screenshot)

<img src=" " alt="HTML Page in WordPress">

And I'm trying to get it so on each submit button, if the record is successfully added to the database a pop up shows up saying "Success!" and then clear the form data without leaving the page. At the moment my current set up tries to load the external page instead of remaining on the page in the screenshot. Here's my HTML and PHP:

&lt;form class="pure-form" name="addAthlete" action="submitForm.php" method="POST"&gt;
    &lt;fieldset class="pure-group"&gt;
        &lt;input type="text" class="pure-input-2" name="membershipID" placeholder="Membership ID"&gt;

        &lt;input type="text" class="pure-input-2" required="required" name="firstName" placeholder="First Name"&gt;

        &lt;input type="text" class="pure-input-2" required="required" name="surname" placeholder="Surname"&gt;

    &lt;button name="submitAthlete" type="submit" class="pure-button pure-input-2 pure-button-primary"&gt;Submit&lt;/button&gt;

function showSuccess() {
    echo "Success! One record added.";

if (isset($_POST['submitAthlete'])) {

function addAthlete() {
    include 'addAthlete.php';

I'm assuming the problem lies with the fact that the echo "Success" is trying to echo on the submitForm.php page which is how I've written it. This is because of the way the page is embedded into wordpress, you can see this below:

add_action( 'admin_menu', 'db_menu' );

function db_menu() {
    'Database Form',     // page title
    'Database Form',     // menu title
    'manage_options',   // capability
    'database-form',     // menu slug
    'wpse_91693_render' // callback function

function wpse_91693_render() {
    global $title;

    print '&lt;div class="wrap"&gt;';
    print "&lt;h1&gt;$title&lt;/h1&gt;";

    $file = plugin_dir_path( __FILE__ ) . "submitform.php";

    if ( file_exists( $file ) )
    require $file;

    print '&lt;/div&gt;';

How can I get a pop up or something to show up within this WordPress page on each submit?