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!

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 Post Variables

I can't see any problems please help me see why I am getting these messages. var_dump didn't work either

Notice: Undefined index: name in C:\xampp\htdocs\contact-process.php on line 3

Notice: Undefined index: email in C:\xampp\htdocs\contact-process.php on line 4

Notice: Undefined index: message in C:\xampp\htdocs\contact-process.php on line 5

My contact page code:

<?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 from you! Complete the form to send me an email.</p>

    <form methed="post" action="contact-process.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'); ?>

My contact-process.php code:

<?php

$name = $_POST["name"]; $email = $_POST["email"]; $message = $_POST["message"]; echo $name; echo $email; echo $message;

?>

1 Answer

Blayne Holland
Blayne Holland
18,817 Points

Try putting the variables above the contact-process.php code.

Code is usually read from top to bottom.