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

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

Problem of html structure when I investigate the code

Hi,

I'm trying to make a php-website but I'm having a problem with my "wrapper" div. When I right-click the page and investigate the code it looks like this:

<body>
<div class="header">...</div>
<div class="wrapper">
  <div class="home">...</div>
  <!-- end of wrapper -->
  <div class="footer">...</div>
</div>
</body>

My problem is I don't want the footer inside the wrapper div and I have no idea why it's in there :-/

Here is my code:

<?php 

$pageTitle = "Home";
$section = "home";

include("inc/header.php"); 

?>
    <div class="wrapper">
        <div class="home">
            <div class="intro">
                <p>Front-End Developer</p>
                <p>located in</p>
                <p>HjΓΈrring, Denmark</p>
            </div>
            <div>
                <a href="portfolio.php" class="work btn">My Work</a>
            </div>
        </div> <!-- end of .home -->
    </div> <!-- end of .wrapper -->

    <?php include("inc/footer.php"); ?>

Original the <div class="wrapper"> was in the inc/header.php and the </div was in the inc/footer.php but I moved them inside the index.php to see if it fixed the problem, sadly it didn't fix it.

Are you sure you are updating your server with the changes? Try renaming something (e.g the comment) to test.

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

I restarted the server and now it works fine again BUT the problem is still on the contact page (only when you make a succesful submit) :-/

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $name = trim(filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING));
    $email = trim(filter_input(INPUT_POST, "email", FILTER_SANITIZE_EMAIL));
    $message = trim(filter_input(INPUT_POST, "message", FILTER_SANITIZE_SPECIAL_CHARS));

    if ($name == "" || $email == "" || $message == "") {
        echo "Please fill in the required fields: Name, Email and Message";
        exit;
    }

    if ($_POST["address"] != "") {
        echo "Bad form input!";
        exit;
    }

    header("location: contact.php?status=thanks");

}

$pageTitle = "Contact";
$section = "contact";

include("inc/header.php");

?>
<div class="wrapper">
    <div class="contact">
        <h2>Contact me</h2>
        <div class="presentation">

            <?php 
            if (isset($_GET["status"]) && $_GET["status"] == "thanks") {
                echo "<p>Thank you very much for the message!<br>I will get back to you as soon as possible!</p>";
            } else {
            ?>

            <p>In case you want to get in touch with me, then please use the form and I will get back to you as soon as possible.</p>
        </div>

        <form method="post" action="contact.php">

            <div id="from">
                <label for="name">Name:</label>
                <input type="text" name="name" id="name">
            </div>
            <div id="reply">
                <label for="email">Email:</label>
                <input type="text" name="email" id="email">
            </div>
            <div id="user_message">
                <label for="message">Message:</label>
                <textarea name="message" id="message"></textarea>
            </div>
            <div style="display:none">
                <label for="address">Address:</label>
                <input type="text" name="address" id="address">
            </div>

            <input type="submit" value="Send">
        </form>

        <?php } ?>

    </div> <!-- end of .contact -->
    </div> <!-- end of .wrapper -->

    <?php include("inc/footer.php"); ?>

1 Answer