I am trying to locate my php header to a specific location on receiving a GET value and if the value is incorrect, it will locate to a default location like home.php
here is what I’ve done so far
<?php
// Check which page is queried
if(isset($_GET['page'])){
$got = $_GET['page'];
}
else {
$got = 'home';
}
// Now goto that location
if(header('Location: '.$got.'.php')){
header('Location: '.$got.'.php');
}
else {
header('Location: home.php');
}
?>
You are probably looking for the file_exists() function.
You would do something like this;
Edit
You would be better of by whitelisting the pages you would allow the users to see:
This ensures that only the views you allow can be accessed.