Logout after don't navigate before page : Login.php and logout.php page provided below.
How to create an session varible and once logout successful don't navigate before page.

     require( 'dbConfig.php');

     session_start();
     $msg = "";
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $name = $_POST["userid"];

    if ($name == '' ) {
        $msg = "You must enter all fields";
    }
    else
    {
        $sql = "SELECT * FROM user WHERE userid = '$name' ";
        $query = mysql_query($sql);

        if ($query === false) {
            echo "Could not successfully run query ($sql) from DB: " . mysql_error();
            exit;
        }

        if (mysql_num_rows($query) > 0) {
            $_SESSION['userid'] = $name;
                header('Location: teams.php');
                exit;
        }

        $msg = "Username do not match";
    }
    }
    ?>

    <?php
    session_start();
    if(session_destroy())
    {
    header("Location: index.php");
    }
    ?>
After logout of the page navigating back pages.please disable solution.