Code is being duplicated due to some php (possibly include code)?
<p>I have a profile system set up and it is all working fine.  However I am trying to do some other styling around the page and have noticed that when I go to view source, the entire page code is duplicated.  It is only duplicated once but none the less there is an exact copy of the code.  The page on which this behavior is being seen is the one that displays the actual profiles.</p>

<p>This is preventing me from styling some other areas and I need to understand why this is happening.</p>

<p>I have posted some code below and can confirm that when I am on the page for which I am seeing the duplicate code, if I take the following out of the controller then it works again:</p>

<pre><code>include 'searchform.html.php';
</code></pre>

<p>This code is however obviously needed for my site but it does prevent a duplicate copy of the code being seen if removed so maybe it might provide a clue to the problem?</p>

<p>I've included the code which I believe is relevant.</p>

<p>INDEX.PHP (EXTRACT)</p>

<pre><code>    // BUILDING THE PLAYER NAME DROP DOWN BOX FOR SEARCHING

    include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';

    try
    {
        $result = $pdo-&gt;query("SELECT id, name, position 
                               FROM player INNER JOIN playerrole
                               ON player.id = playerid
                               WHERE roleid = 'Player'
                               ORDER BY position, name");

    }
    catch (PDOException $e)
    {
        $error = 'Error fetching player names from database!' . $e-&gt;getMessage();
        include 'error.html.php';
        exit();
    }
    // Added age to here to get it as a value under the search results heading and had to put it in above select query
    foreach ($result as $row)
    {
        $names[] = array('id' =&gt; $row['id'], 'name' =&gt; $row['name'], 'position' =&gt; $row['position']);
    }

    include 'searchform.html.php';

    // SQL STATEMENT THAT PERFORMS THE SEARCH

    if (isset($_GET['action']) and $_GET['action'] == 'search')
    {
        include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';

            $id = $_GET['name'];
            $text = $_GET['text'];

        $params = '';

        if($id !== '')
        {
            $params = "player.id = '$id'";
        } 
        else if($text !== '')
        {
            $params = "player.name LIKE '%$text%'";
        }
        else if($id == '')
        {
            $selectError = 'Please either select a name from the drop down list or enter the name of a player';
        }

        try
        {

        $sql = "SELECT player.id, player.name AS name, age, position, height, weight, previousclubs.name AS previousclubs, 
                satscore, gpa, link, email
                FROM player INNER JOIN playerpreviousclubs
                    ON player.id = playerid
                INNER JOIN previousclubs
                    ON previousclubid = previousclubs.id
                INNER JOIN links
                    ON links.playerid = player.id
                WHERE {$params}";

        $s = $pdo-&gt;query($sql);
        }
        catch (PDOException $e)
        {
            $error = 'You have not selected or entered a name.' /*. $e-&gt;getMessage()*/;
            include 'error.html.php';
            exit();
        }
        // This is responsible for populating the new player info underneath all
        foreach ($s as $row)
        {
            $results[] = array(
                                'id' =&gt; $row['id'], 
                                'name' =&gt; $row['name'], 
                                'age' =&gt; $row['age'], 
                                'position' =&gt; $row['position'], 
                                'height' =&gt; $row['height'], 
                                'weight' =&gt; $row['weight'], 
                                'satscore' =&gt; $row['satscore'], 
                                'gpa' =&gt; $row['gpa'],
                                'previousclubs' =&gt; $row['previousclubs'], 
                                'links' =&gt; explode(',',$row['link']),
                                'email' =&gt; $row['email']
                                );
        }
        include 'profiles.html.php';
        exit();
    }
</code></pre>

<p>SEARCHFORM.HTML.PHP (EXTRACT)</p>

<pre><code>    &lt;div id="Profile" class="Profile"  &gt;

    &lt;h1&gt;Player Profile Search&lt;/h1&gt;

    &lt;p&gt;Please either select a name from the drop down box or enter part of the name into the search field and click the search button.&lt;/p&gt;

    &lt;form action="" method="get"&gt;

    &lt;ol&gt;

    &lt;li class="bold"&gt;&lt;label for="name"&gt;By Position / Name:&lt;/label&gt;&lt;/li&gt;

    &lt;li&gt;
    &lt;select name="name" id="name"&gt;
    &lt;option value=""&gt;Position / Name&lt;/option&gt;
    &lt;!-- populates the drop down with names --&gt;
    &lt;?php foreach ($names as $name): ?&gt;
    &lt;option value="&lt;?php htmlout($name['id']); ?&gt;"&gt;
    &lt;?php htmlout($name['position']); ?&gt; / &lt;?php htmlout($name['name']); ?&gt;
    &lt;/option&gt;
    &lt;?php endforeach; ?&gt;
    &lt;?php if (isset($selectError)): ?&gt;
    &lt;p&gt;&lt;?php htmlout($selectError); ?&gt;&lt;/p&gt;
    &lt;?php endif; ?&gt;
    &lt;/select&gt;
    &lt;/li&gt;

    &lt;li class="bold"&gt;&lt;label for="text"&gt;Containing text:&lt;/label&gt;&lt;/li&gt;
    &lt;li&gt;&lt;input type="text" name="text" id="text"&gt;&lt;/li&gt;

    &lt;li&gt;&lt;input type="hidden" name="action" value="search"&gt;&lt;/li&gt;
    &lt;li&gt;&lt;input type="submit" value="Search" class="button search"&gt;&lt;/li&gt;

    &lt;/ol&gt;

    &lt;/form&gt;

    &lt;!--&lt;p class="return"&gt;&lt;a href=".."&gt;Return to JMS home&lt;/a&gt;&lt;/p&gt;--&gt;
    &lt;li class="logout"&gt;&lt;?php include '../includes/logout.inc.html.php'; ?&gt;&lt;/li&gt;

    &lt;/div&gt;
</code></pre>

<p>Thanks for any help that you can provide.</p>

<p>PROFILES.HTML.PHP (EXTRACT)</p>

<pre><code>    &lt;div id="Profile" class="Profile"  &gt;

    &lt;h1 class="margin-top"&gt;Search Results&lt;/h1&gt;

    &lt;?php if (isset($results)): ?&gt;

    &lt;?php foreach ($results as $result): ?&gt;

    &lt;ol class="coach-display"&gt;

    &lt;li class="left image"&gt;&lt;img src="&lt;?php echo('?action=view&amp;id=' . $result['id']); ?&gt;" width="180" height="240" /&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Name:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['name']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Age:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['age']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Position:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['position']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Height:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['height']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Weight:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['weight']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Sat Score:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['satscore']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;GPA:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['gpa']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Previous Clubs:&lt;/li&gt;
    &lt;li&gt;&lt;?php htmlout($result['previousclubs']); ?&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Email:&lt;/li&gt;
    &lt;li&gt;&lt;a href="mailto:&lt;?php htmlout($result['email']); ?&gt;"&gt;&lt;?php htmlout($result['email']); ?&gt;&lt;/a&gt;&lt;/li&gt;

    &lt;li class="listleft"&gt;Links:&lt;/li&gt;
    &lt;?php foreach($result['links'] as $link) 
    { 
        $link = trim($link);
        echo '&lt;li class="inline"&gt;&lt;a href="http://'.$link.'"target="_blank"&gt;'.$link.'&lt;/a&gt;&lt;/li&gt;';
    } 
    ?&gt;


    &lt;/ol&gt;

    &lt;form action="?" method="post"&gt;

    &lt;div id="buttons"&gt;


    &lt;/div&gt;
    &lt;/form&gt;

    &lt;?php endforeach; ?&gt;

    &lt;?php endif; ?&gt;

    &lt;h3 class="bold"&gt;&lt;a href="?"&gt;New search&lt;/a&gt;&lt;/h3&gt;
    &lt;li class="logout"&gt;&lt;?php include '../includes/logout.inc.html.php'; ?&gt;&lt;/li&gt;

    &lt;/div&gt;
</code></pre>

<p>LOGOUT.INC.HTML.PHP</p>

<pre><code>    &lt;form action="" method="post"&gt;
    &lt;div&gt;
    &lt;input type="hidden" name="action" value="logout"&gt;
    &lt;input type="hidden" name="goto" value="/login.html"&gt;
    &lt;input type="submit" value="Log out" class="button"&gt;
    &lt;/div&gt;
    &lt;/form&gt;
</code></pre>
