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

Working with Post Variables

I had an error where my $_POST variable would not display the form submission elements. Instead, it would display and empty array. The solution was to add an = sign to the name attribute (shown below). I can not believe I over-looked something so simple. I was checking for configuration errors when it was a simple typo the entire time.

Submission would still work, but there was no name on the input elements for POST to create an array.

I will go ahead and leave this forum post up. It may benefit someone experiencing an issue with receiving the ' array(0) {} ' message.

        <form method="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>

1 Answer

You must write input name attribute with a equal sign before like name="my_input_name" no like was you doing... name"my_input_name".