i have a page with 4 links namely 1st.php, 2nd.php, 3rd.php, and 4th.php. my index.php displays the 3rd.php as default. i also created a 404.php (error page) so that when a user edits the URL it will not redirect to the index.php, instead it will display the error page. the problem is when i open my index.php page, it displays the error page instead. need help. this is my code:
<?php
$quarters = array('Q1', 'Q2', 'Q3', 'Q4');
$quarter = 'Q3';
if(isset($_GET['quarter']) && in_array($_GET['quarter'], $quarters)) {
$quarter = $_GET['quarter'];
}
switch($quarter) {
case 'Q1' :
$quarter = 'firstq2012.php';
break;
case 'Q2' :
$quarter = 'secondq2012.php';
break;
case 'Q3' :
$quarter = 'thirdq2012.php';
break;
case 'Q4' :
$quarter = 'fourthq2012.php';
break;
}
$pages = array('Q1','Q2','Q3','Q4');
if (in_array($_GET['quarter'], $pages)){
include_once $quarter;
}
else {
header('Location: 404.php');
}
?>