• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

php help...

_Street_Fighter

New Member
k - im doing one of those page.php?cat=name&id=1

heres an example of my page.php
PHP:
<html>
<head>
<title>BLaH BLaH BLaH</title>
</head>

<body>

// I'll add my layout stuff here...

<? 
if (!empty($cat) && !empty($id)) { 
include("$cat$id.php"); 
} else { 
include("news.php"); 
} 
?>

// I'll add my layout stuff here...

</body>
</html>

what i want it to do is to include the "$cat$id.php" only if that page exists... so if the visitor types in whatever they want, it'll show news.php instead of an error or a blank page...

- SF
 
PHP:
<? 
if (!empty($cat) && !empty($id)) { 
$file = $cat.$id.".php";
if(file_exists($file)==1) {
include("$cat$id.php"); 
} 
} else { 
include("news.php"); 
}
?>
 
Back
Top