Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Creating the Menu and Footer Including the Header

Issues with header.php

I'm having issues with my header.php file loading up correctly to the webpage. When Randy Hoyt in the video his page looks the way it should. When I refresh mine I get a white background with all of the pictures still there.

Help!

Here is my header.php

<html> <head> <title>Shirts 4 Mike</title> <link rel="stylesheet" href="css/style.css" type="text/css"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css"> <link rel="shortcut icon" href="favicon.ico"> </head> <body>

<div class="header">

    <div class="wrapper">

        <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

        <ul class="nav">
            <li class="shirts"><a href="#">Shirts</a></li>
            <li class="contact"><a href="contact.php">Contact</a></li>
            <li class="cart"><a href="#">Shopping Cart</a></li>
        </ul>

    </div>

</div>

<div id="content">

Here is the link code used in both the index.html and contact.php

<p>?php include('inc.header.php'); ?></p>

I had to remove the "less than symbol" symbol so it would appear but it would be in front of the code.

1 Answer

Cosmin Cioaclă
Cosmin Cioaclă
21,339 Points

Hi Ira,

Looking at your code, I see that you are missing the opening html tag, as well as the head, /head and body tags.

The whole thing should be in a file called header.php situated in a folder called inc. To include that in your index.php page, you would have the following line at the begining of your file:

<?php include('inc/header.php'); ?>

Make sure your index has the .php extension, not .html.

Hope that helps, Cosmin