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 trialasaf omri
Courses Plus Student 2,784 PointsWhat's wrong with this code?
$_POST['username'] = $username;
$_POST['password'] = $password;
if($username == '' or $password == '') {
header("location: index.php");
exit;
}
if(!empty($username) or !empty($password)) {
echo 'you logged in';
}
it doesn't echo you logged in on login.php which is the processing
1 Answer
Erik McClintock
45,783 PointsAsaf,
It's hard to say without seeing the form itself. At the outset, try swapping the placement of your $_POST variables and regular variables, like follows:
$username = $_POST['username'];
$password = $_POST['password'];
See if that does the trick.
Other things to check:
1) Is your form pointing to login.php as its action? 2) Are you checking if a submit button has been hit/'isset'?
Erik