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


$_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">
                <input type="text" name="username">
                <input type="password" name="pass">
                <input type="submit" value="LOGIN">

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


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.