Ryan Regards
Ryan Regards

Reputation: 9

PHP If Statement Issue

I am working on something, but with my if statements, it will say "test" no matter what, not following the other if statements. Help please, heres my code:

<?php
$userr = $_POST['user'];
$user = ucwords($userr);
$pass = $_POST['pass'];
if ($submit) 
{
    if ($userr && $pass) 
    {
        if ($user == "Admin" && $pass == "password") 
        {
            echo "Logged in";
        } 
        else 
        {
            echo "Fill in all fields";
        }
    } 
    else 
    {
        echo "Submit!";
    }
} 
else 
{
    echo "test";
}
?>

Upvotes: 1

Views: 53

Answers (2)

Madara&#39;s Ghost
Madara&#39;s Ghost

Reputation: 174957

That's most likely because $submit always evaluates to false.

Make sure that $submit is defined and is what you expect it to be.

Also, if $user == 'false' your script will break without warning.

Upvotes: 0

hjpotter92
hjpotter92

Reputation: 80639

Where are initializing your $submit?

By a look at your code, I think you need:

$submit = $_POST['submit'];

Upvotes: 1

Related Questions