...

View Full Version : Some help with 404 errors



tomrshl
11-02-2009, 07:46 PM
if (isset($_GET["id"]))
{
$id = $_GET["id"];
}

function main($id) {
if (file_exists($filename = "main/$id.php"))
{
include "$filename";
}
}

main() is called using the parameter ?id=* and includes a file of the same name. What would be the standard way of me producing a 404 error should $id.php not exist? I don't want to use .htaccess
I only have a little bit of experience in PHP so if you see something unrelated wrong with my code, let me know :)

met
11-02-2009, 08:09 PM
function main($id) {
if (file_exists($filename = "main/$id.php"))
{
include "$filename";
} else {
header("HTTP/1.0 404 Not Found");
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum