if (empty($_GET['gstr'])){  
                    header("location:index.php");  
                    }else{
şurayı ve bu ifi kapattığın parantezi sil yani en sondakini sonra en başa

if (empty($_GET['gstr'])){header("location:index.php");exit;}
bunu yaz buda olmazsa artık :d