Ascendant Posted January 28, 2008 Share Posted January 28, 2008 <?php $config["path"] = ""; $config["ext"] = ".php"; if (!isset($_REQUEST["page"])){ $page = "main"; } else { $page = $_REQUEST["page"]; $page = urldecode($page); $page = trim($page); $page = strip_tags($page); if (substr_count($page,"..") > 0 || substr_count($page,"~") > 0){ $page = "main"; } } $full = $config["path"] . $page . $config["ext"]; if (!is_file($full) || is_dir($full) || !file_exists($full)){ die ("Unfortuantly the page you have requested can either not be found, or has timed out. Please contact oliver@iacademia if the problem persists."); } else { require_once($full); } ?> This is the current bit of request code im using on my site currently. Yet its not flexible enough, for example, if I load up index?page=about then have a hyperlink inside about.php to another page, say, login.php, it wont work. I need more flexibility, and I have noticed that sites are using hyperlinks that not only have the index?page=about, but also a wierd chunk of code that includes &: index.php?page=main&file=article&sid=77 Can anybody help me edit my code to incorporate is file and sid variable? Quote Link to comment https://forums.phpfreaks.com/topic/88149-php-help-moderate-noob-here/ Share on other sites More sharing options...
mem0ri Posted January 28, 2008 Share Posted January 28, 2008 If you're intending to have the same "layout" for your pages, you can always load each new page 'inside' of the index page...kind of like: <?php require_once('header.php'); if(!isset($_REQUEST['page'])) $page = 'main'; else $page = $_REQUEST['page']; require_once($page.'.php'); require_once('footer.php'); In that fashion, you can reference every page on the site through index.php?page=x As far as including file and sid... You'd just be adding another layer of $_GET variables that would either trigger (or not trigger) additional file-loads... Quote Link to comment https://forums.phpfreaks.com/topic/88149-php-help-moderate-noob-here/#findComment-451019 Share on other sites More sharing options...
Ascendant Posted January 28, 2008 Author Share Posted January 28, 2008 I require an extra layer of these $_GET variables. Could you give me an example of my code included with this extra layer? I learn best with examples... Thanks buddy. Quote Link to comment https://forums.phpfreaks.com/topic/88149-php-help-moderate-noob-here/#findComment-451025 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.