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

Trevor Wood
Trevor Wood
17,828 Points

Quick question on build a simple PHP app

Hey guys, just got finished watching "Checking the Request Method" in Stage 3, Adding a Contact Form, under build a simple PHP app.

I'm having trouble getting the website to show up. As it is, it's just a blank white screen when I try to go to contact.php

Here's the code, any help would be much appreciated!

 <?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;

header("Location: contact-thanks.php");
exit;

}

?><?php $pageTitle = "Contact Mike"; $section = "contact";

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

<div class="section page">

    <div class="wrapper">

        <h1>Contact</h1>

        <p>I&rsquo;d love to hear form 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>

    </div>

</div>

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

1 Answer

Trevor Wood
Trevor Wood
17,828 Points

Ah, fixed it, it's that "?" behind request method. deleted it and it fixed it.

odd though, it showed up as a space in the code O.o