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

$_POST problems

I feel like this is a dumb question, but:

I have this in my login.php: if(isset($_POST['username']))

and the following form in the main page

<form action="login.php" method="POST" enctype="text/plain" class="login">
    <table>
        <tr>
            <td>
                <label>USERNAME</label>
            </td>
            <td>
                <input type="text" name="username">
            </td>
            <td>
                <label>PASSWORD</label>
            </td>
            <td>
                <input type="password" name="pass">
            </td>
            <td>
                <input type="submit" value="LOGIN">
            </td>
        </tr>
    </table>
</form>

why is it telling me that $_POST['username'] isn't set?

4 Answers

the url was like http://www.insertwebsitehere.com/pagename.php?getvariable and the get variable was conflicting with the $_POST array so that was my problem

Wendell,

The most fundamental reason is that you may not have submitted the username--in other words, so it becomes part of the $_POST array.

Oh holy cow. I figured out the problem. I had a get variable set when I submitted the form. Good heavens the staff must be getting sick of me now posting stuff like this. Sorry

Ah, so--it was a submission problem.