how would I write an IF statement that says if $req does not blank and equals string that does not exist then load, load_template(tpl_path.'err404.tpl'); so if $req does not match or equal something that is valid then show error page.
if ($req == '') load_template(tpl_path.'index.tpl');
if ($req == 'dologin') include 'includes/dologin.php';
if (!isset($req) || $req == '') { ... } elseif ($req == 'do') { ... } - ShinTakezou 2012-04-04 05:52
Use a switch statement:
switch($req) {
case '':
load_template(tpl_path.'index.tpl');
break;
case 'dologin':
include 'includes/dologin.php';
break;
default:
load_template(tpl_path.'err404.tpl');
}
$req itself doesn't exist, just that its value is a non-blank string that "does not exist" - Emil Vikström 2012-04-04 05:54
else in if else or default in switch case... so the answer is perfect for him - noob 2012-04-04 05:56
switch :) or you could simply change your if statements to elseifs (and a final else displaying the 404): if (nothing) default-page elseif (something) some-page elseif (anotherthing) another-page else 404-pagepowerbuoy 2012-04-04 06:02
$req and look if it matches a .tpl file in the file system. If so, then include it, otherwise throw 404.« Hardcoding the possible choices is easier than solving the possible security problems though, at least for a small number of choices. EDIT Oh, nevermind, they said that already. But didn't update the question - Joey 2012-04-04 07:52