you are using to include function to redirect.
try using header function;
example:
header('Location: '.location.'.php');
create a function like below:
function isset_val(&$var,$new)
{
if(isset($var)==true)
return $var;
return $new;
}
now call the function like below:
$location=isset_val($_GET['location'],'index');
fix rest of the issues