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 Adding a Contact Form Working with Get Variables

Getting blank contact page after applying code in working with variables.

Can't figure out whats wrong. Hope I'm not asking too many questions.Thank you all for your help.

<?php

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

$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
$email_body = "";
$email_body = $email_body . "Name: " . $name . "\n";
$email_body = $email_body . "Email: " . $email . "\n";
$email_body = $email_body . "Message: " . $message;


// TODO: Send Email

header("Location: contact.php?status=thanks");
exit;
}
?>

<?php 
$pageTitle ="Contact Mike";
$section = "contact";
include('inc/header.php'); ?>

    <div class="section page">

        <div class="wrapper"
            <hl>Contact</hl>

            <?php if (isset($_GET["status"]) AND ($_GET["status"] == "thanks") { ?>
            <p>Thanks for the email! I will be in touch shortly.</p>
            <?php } else { ?>

                <p>I&rsquo;d love to hear from you! Complete the form to send me an email.</p>
                <form method="post" action="contact.php">
                <table>
                    <tr>
                        <th>
                            <label for "name">Name</label> 
                        </th>
                        <td><input type="text" name="name" id="name">
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <label for "email">Email</label> 
                        </th>
                        <td><input type="text" name="email" id="email">
                        </td>
                    </tr>
                        <tr>
                        <th>
                            <label for "message">Message</label> 
                        </th>
                        <td>
                            <textarea name="message" id="message"></textarea>
                        </td>
                    </tr>
                </table>
                    <input type="submit" value="Send">
                </form>
            <?php } ?>

        </div>
    </div> 

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

2 Answers

Apply an equal sign to all your label for's.

<label for="message">Message</label> 

good catch, they were missing, but didn't solve the problem. And form had been showing up even without that previously though glad its fixed now. any other ideas?

alan heath
alan heath
5,188 Points

Did you ever get a solution to this problem? I have the same problem.

Hi Alan, Haven't had chance to get back to that course for past couple of weeks, and don't think I hadn't gotten to point of resolving issue. Will probably resume next week so let you know if I find solution. Also in interim let me know if you do! Thanks, Sharon

Omahr B. Carpinteyro
seal-mask
.a{fill-rule:evenodd;}techdegree
Omahr B. Carpinteyro
Front End Web Development Techdegree Student 4,684 Points

Hi! I got this same issue because of two errors in the same line with the curly brackets {

ciao!

            <?php} else ?>       //incorrect
            <?php } else {?>    //correct

          ```