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

Dr.P reon
Dr.P reon
8,562 Points

contact page still wont load!!!!

I am still having trouble loading the contact page. and this is a real pain. I have spent over two days working on this and i dont seem to be going anywhere. Each time I refresh url localhost, this pops up " localhost/#". My index page, contact page and header page looks like this

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

<html> <head> <title><?php echo "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</a></li>
            <li class="cart"><a href="#">Shopping Cart</a></li>
        </ul>

    </div>

</div>

<div id="content">

    <div class="section banner">

        <div class="wrapper">

            <img class="hero" src="img/mike-the-frog.png" alt="Mike the Frog says:">
            <div class="button">
                <a href="#">
                    <h2>Hey, I&rsquo;m Mike!</h2>
                    <p>Check Out My Shirts</p>
                </a>
            </div>
        </div>

    </div>

    <div class="section shirts latest">

        <div class="wrapper">

            <h2>Mike&rsquo;s Latest Shirts</h2>

            <ul class="products">
                <li><a href="#">
                        <img src="img/shirts/shirt-108.jpg">
                        <p>View Details</p>
                    </a>
                </li><li>
                    <a href="#">
                        <img src="img/shirts/shirt-107.jpg">
                        <p>View Details</p>
                    </a>
                </li><li>
                    <a href="#">
                        <img src="img/shirts/shirt-106.jpg">
                        <p>View Details</p>
                    </a>
                </li><li>
                    <a href="#">
                        <img src="img/shirts/shirt-105.jpg">
                        <p>View Details</p>
                    </a>
                </li>                               
            </ul>

        </div>

    </div>

</div>

<div class="footer">

    <div class="wrapper">

        <ul>        
            <li><a href="http://twitter.com/treehouse">Twitter</a></li>
            <li><a href="https://www.facebook.com/TeamTreehouse">Facebook</a></li>
        </ul>

        <p>&copy;<?php echo date('Y'); ?> Shirts 4 Mike</p>

    </div>

</div>

</body> </html>

Contact Page

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

<div class="section page">

 <h1>Contact</h1>

</div>

Header Page

<html> <head> <title><?php echo "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">

Since I cant copy and paste screenshots in the text area, I am going to print a structure of my htdocs directory which is as follows

htdocs Folder
  css folder
  forbidden folder
  img folder
  inc folder
     header file
  restricted folder
  xampp folder
  DS_store file
  contact.php file
  favicon.ico file
  index.php file
  test.php file

is Your contact us page an actual page or all three pages different section of ONE whole page? I am asking because for other links you have a # and for contacts you have the actual link?

also you have a header.php where you are linking to contacts.php BUT in your index.php you are not INCLUDING this file and i can see all links having a #.. maybe this is your problem

Dr.P reon
Dr.P reon
8,562 Points

@shex azr, I included the header.php page in index.php and contact.php using this php code

<?php include("header.php"); ?>

sorry, the php code is not showing up in the text area for some reason...

Matt Trask
Matt Trask
10,027 Points

@Uchenna, use markdown and the Markdown cheat sheet to display code in the text areas.

Looking at index.php, I don't see any includes. Are you sure they are set?

3 Answers

Matt Trask
Matt Trask
10,027 Points

on the index page, the link is still looking at "#" instead of "contact.php". That would be my first guess.

Dr.P reon
Dr.P reon
8,562 Points

Thanks matt, I used the markdown cheatsheat and this is what my page looks like....

index page

<?php include('inc/header.php'); ?> <html> <head> <title><?php echo "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">

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

<div class="section page">

 <h1>Contact</h1>

</div>

Well the header page has no include statement. Yes I am very sure I added the include statement in both index page and contact page.

Matt Trask
Matt Trask
10,027 Points

Its been a while since Ive done this track, but isn't the css and title supposed to be in the header file? If so, you seem to be calling it twice, once in the include, but then you still have everything in the file.

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

<div id="content">
</div>

Im pretty sure that is how it should look in index.php

Robert Wasinger
Robert Wasinger
12,385 Points

Uchenna,

Thanks for posting each of your sections.

Your index.php file is not including your header.php file.

index.php

<title><?php echo "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">



<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</a></li>
            <li class="cart"><a href="#">Shopping Cart</a></li>
        </ul>

    </div>

If you look at the code that is presently in your index.php (which I have displayed above). The contacts link is showing

<li class="contact"><a href="#">Contact</a></li>

This is the contact link is going to localhost/#.

You can fix it by updating the link in your index.php to

<li class="contact"><a href="contact.php">Contact</a></li>

OR by removing the duplicate code and including the header file as Matt suggested.

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

Hope this helps! I recently completed the track your on. PHP can be challenging to debug because almost everything results in either a blank screen or server error 500.