if/else won't go into else <p>I wrote an if/else statement for a login page, I already used it before in other pages and it works. It doesn't seem to work now however. The if part works, but it won't get to the else part. (I shortened the code normally the if will do a lot more but because that's already working I only focus on the else part here). Thanks in advance!</p> <pre><code> $error = false; if (**isset**($_POST['username']) &amp;&amp; **isset**($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; } else { $error = true; } if(!$error){ echo 'it worked'; } else { echo 'not all fields are filled in'; } </code></pre> <p>Maybe I should tell you that it's not the bottom else but it's the top one which doesn't work. Because if I change $error to true it works. It just doesn't get into the else which changes error to true. </p>