Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/169809-directory-script-not-working/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.