Is this a good way to create a dynamic webpage using PHP? -
i'm trying create dynamic webpage using include()
in php. php page has following codes - literally, that's file contains:
<?php session_start(); $dbname = $_request['dbname']; $tbname = $_request['tbname']; $dbtype = $_request['dbtype']; include('header.php'); switch($dbtype) { case 'calender': include('calenderpage.php'); exit; case 'news': include('newspage.php'); exit; case 'gallery': include('gallerypage.php'); exit; } include('footer.php'); ?>
do think it's way of creating dynamic php page?
what show fine. done bit simpler using array:
<?php session_start(); // explicitly using $_get or $_post better $_request $dbname = $_get['dbname']; $tbname = $_get['tbname']; $dbtype = $_get['dbtype']; include('header.php'); // sure have array of allowed pages // people can't access pages they're not supposed access $allowed_pages = array("calender", "news", "gallery"); if (in_array($dbtype, $allowed_pages)) include($dbtype."page.php"); else die("unknown page"); include('footer.php'); ?>
Comments
Post a Comment