Page 2 of 2

Posted: Wed Mar 21, 2007 8:46 pm
by andylyon87
hey guys just thought Id get your opinion is this any good now. Thanks for the help so far has been awesome.

Code: Select all

$id = isset($_GET['id']) ? $_GET['id'] : 'home';
				if($id){
    				$id = isset($_GET['id']);
    				if (ctype_alnum($id)){
        				$file = "php/$id.php";
        				if(file_exists($file)){
            				include $file;
        				}else{
            				echo '<p class="center"> The page: <span class="bold">' . $id . '.php</span> you requested is unavailable at the present time please try refreshing the page or try again later, your error has been logged and the problem will be fixed shortly.</p>';
        				}
    				}else{
        				include 'php/home.php';
    				}
				}
have used bits of everyones advice hope its decent let me know if you think its too messy.

Andy

Posted: Wed Mar 21, 2007 10:23 pm
by andylyon87
yeh I realised the above didnt actually work and edited it down to the below, which (as it happens) works:

Code: Select all

if(isset($_GET['id'])){
    				$id = isset($_GET['id']) ? $_GET['id'] : 'home';
    				if (ctype_alnum($id)){
        				$file = "php/$id.php";
        				if(file_exists($file)){
            				include $file;
        				}else{
            				echo '<p class="center"> The page: <span class="bold">' . $id . '.php</span> you requested is unavailable at the present time please try refreshing the page or try again later, your error has been logged and the problem will be fixed shortly.</p>';
        				}
    				}else{
        				include 'php/home.php';
    				}
				}