1

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";
}
?>
6
  • 2
    a random guess: is $submit always evaluated to false? Commented Sep 16, 2012 at 8:59
  • 2
    What would happen when the user false would register? or 000000? or null? Commented Sep 16, 2012 at 9:01
  • as @AndreasHenning said, theres nothing that would set $submit to true. wild guess, change it to $_POST['submit'] ? Commented Sep 16, 2012 at 9:02
  • I am makign this for a friend, doesn't need to really be regulated. Commented Sep 16, 2012 at 9:02
  • Use ALWAYS strict comparisons === with passwords!! Commented Sep 16, 2012 at 9:05

2 Answers 2

1

Where are initializing your $submit?

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

$submit = $_POST['submit'];
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.