title: PHP include content and move to an id anchor fails to load
body: <p>I am trying to load some content with php, and some of the navigation links refer to an anchor tag.  </p>
  
  <p>when the page loads there is a nav list, and I can click on any of the items which will scroll the page to the correct anchor.  If I click the last item (forum) it loads different content, and I can never go back to the original content.</p>
  
  <p>If I change one of the links to be just href="index.php?content=main then that link will reload the main content.  So for some reason the anchor tag # is causing this to fail, if I change the last link to be href="index.php?content=forum#test" then the forum content will not load either.</p>
  
  <p>Is there some fundamental mistake I am making or can this not be done in this way?</p>
  
  <p>I can right click on the link and open in a new tab and they work fine and scroll to the correct anchor.  A left click just seems to do nothing, not even a change in the address bar.</p>
  
  <p>Here is the code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- navigation menu --&gt;
      &lt;ul id="navigation"&gt;
        &lt;li&gt;&lt;a href="index.php?content=main#action" class="active"&gt;Living The Dream&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="index.php?content=main#about"&gt;About&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="index.php?content=main#reality"&gt;The Reality&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="index.php?content=main#setup"&gt;Downloads &amp; Setup&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="index.php?content=forum"&gt;Forum&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt; 
      &lt;!-- end of navigation menu --&gt;
        
    &lt;/div&gt; 
  &lt;!-- end of the sidebar --&gt;
      
  &lt;!-- content container --&gt;
    &lt;div id="container"&gt; 
      &lt;?php 
          if (isset($_GET['content']))
              {
              $parts = explode('#', $_GET['content']);
              print_r($parts);
              $content = $parts[0];
              $content .= '.php';
              }
          else
              {
              $content="main.php";
              }
          $allowed = Array();
  
          $dh = opendir(".");
          while (false !== ($file = readdir($dh)))
              {
                  if (!is_dir("./$file"))
                      {
                          $expl = explode('.',$file);
                          if ($expl[1] == "php")
                              {
                                  $allowed[] = $file;
                              }
                      }
              }
  
          closedir($dh);
  
          print($content);
  
          if (in_array($content, $allowed))
              {
                  include($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$content);
              }
              else
              {
                  include($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."main.php");
              }
        ?&gt;</code></pre>
  </div>
  </div>
  </p>