darkfreaks Posted August 11, 2009 Share Posted August 11, 2009 Current Script: <?php // Wherever you keep the page files $sub_path = getcwd() . '/portfolio'; // .php do not change $sub_extension = '.php'; // Page shown by default (filename not url) no need for an array since this script reads all the pages in the directory $sub_default = 'stateoftheunion'; function show_error($msg) { echo "<h1>Error</h1>\n"; echo "<span>" . $msg . "</span>\n"; } function sub_include() { global $sub_path, $sub_extension, $sub_default; $sub_filename = isset($_GET['design']) ? $_GET['design'] : $sub_default; if (!$sub_filename) { show_error('No page selected.'); return; } foreach (array('.', '/', '\\') as $sub_illegal) { if (false !== strpos($sub_filename, $sub_illegal)) { show_error('Illegal characters in page parameter.'); return; } } $sub_fullpath = realpath(sprintf('%s/%s.%s', $sub_path, $sub_filename, $sub_extension)); if (!file_exists($sub_fullpath)) { show_error('This page has not been created yet.'); return; } include($sub_fullpath); } ?> and when i put <a href="?page=portfolio&design=stateoftheunion"> it does not pull up the page at all rather does nothing. Quote Link to comment https://forums.phpfreaks.com/topic/169809-directory-script-not-working/ Share on other sites More sharing options...
wildteen88 Posted August 11, 2009 Share Posted August 11, 2009 Your code just defines a few variables and two functions. Without calling any of the functions nothing will happen. Judging by your code it looks like you need to call the sub_include() function for anything to happen. Quote Link to comment https://forums.phpfreaks.com/topic/169809-directory-script-not-working/#findComment-895816 Share on other sites More sharing options...
darkfreaks Posted August 11, 2009 Author Share Posted August 11, 2009 nevermind i just realized that portfolio is a directory not a file how would i change this code instead of grabbing mysite.com/portfolio.php it grabs mysite.com/portfolio/myfile.php Quote Link to comment https://forums.phpfreaks.com/topic/169809-directory-script-not-working/#findComment-895836 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.