无法在window.location中检索会话值

the session value should be ok, but I could not retrieve in window.location, can someone help?

echo "<script>window.location='index.php?' + 'gp_name=' + '<?php echo $gname';?>'</script>";

code:

require_once 'connection.php';
session_start();
$gname = $_SESSION['gp_name'];

if(ISSET($_POST['submit'])){
    if($_FILES['upload']['name'] != "") {
        $file = $_FILES['upload'];
        $file_name = $file['name'];
        $file_temp = $file['tmp_name'];$name = explode('.', $file_name);
        $path = "files/".$file_name;

        $conn->query("INSERT INTO `file` VALUES('', '$gname', '$name[0]', '$path')") or die(mysqli_error());

        move_uploaded_file($file_temp, $path);
        header("location:index.php");

    }else{
        echo "<script>alert('Required Field!')</script>";
        echo "<script>window.location='index.php?' + 'gp_name=' + '<?php echo $gname';?>'</script>";
    }
}