As it happens (in case anyone else is reading this) the code as written is invalid: "$gid && $id" is not a variable, and isset() only works with variables. The test would need to be if(!isset($gid) && !isset($id)).
And to add to cahva's comment; if $POST['gid'] is not set, then the line $gid=$POST['gid'] would trigger a Notice-level message about an uninitialized variable or array index.