10-30-2007, 12:32 AM
|
#6 (permalink)
|
|
The Wanderer
Join Date: Oct 2007
Posts: 21
Thanks: 1
|
Quote:
Originally Posted by obolus
heh, true. Thanks for the feedback!
I put up simple but nice custom error pages for 401, 403, 404, 500, and 503 errors.
One thing I need to do is find a way to redirect the user in a similar situation. Right now, the url system uses a bunch of elseif statements to determine what page to display to the user. If I put in a bad query (ie page.php?wrong instead of page.php?right) in my browser, I just get a blank page.
The elseif statements look like so (dont mind the messy code)...
PHP Code:
<?php
if(!$_SERVER['QUERY_STRING']) { ?>
<?php
// blank query displays default page (index.php)
?>
<? elseif ($_SERVER['QUERY_STRING'] == "page") ?>
<?php
// display page with index.php?page as url
?>
So, and especially in the future when I might be working with session id's for users (appended to the end of url's), how do I code it to look for bad queries? Thanks all.
|
I would recommend using a simple switch() statement:
Code:
<?php
switch ($_SERVER['QUERY_STRING'])
{
case 'right':
//display page
break;
default: //Anything not matched by the other cases (blank, wrong etc)
//default page
}
?>
|
|
|
|