title: What's wrong whit this php login page?
body: <p>I am very new to web development, working on a school project right now.
  I have a problem with my login code, but I can't figure out what it is.
  When I submit the form, the page seems to just reload and no session is being set.</p>
  
  <p>My shortened login page:</p>
  
  <pre><code>&lt;?php include "connect.php";
  
  if (isset($POST['login'])) {
      $user_email_username = mysqli_real_escape_string($link, $_POST['email_username']);
      $user_password = mysqli_real_escape_string($link, $_POST['password']);
  
      $email_username_query = mysqli_query($link, "SELECT * FROM User WHERE email='$user_email_username' OR username='$user_email_username'");
  
      if (mysqli_num_rows($email_username_query) == 0) {
          $not_registered_error = "It looks like you still don't have an account. &lt;a href=\"signup.php\"&gt;Sign up&lt;/a&gt;.";
      } else {
          $row = mysqli_fetch_array($email_username_query);
          if (sha1($user_password) != $row['password']) {
              $wrong_password_error = "The password you submitted is wrong.";
          } else {
              $_SESSION['user_id'] = $row['idUser'];
              $_SESSION['user_name'] = $row['name'];
              $_SESSION['user_username'] = $row['username'];
              header("Location: index.php");
          }
      }
  }
  ?&gt;
  &lt;!--metadata--&gt;
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-6 col-md-offset-3"&gt;
              &lt;div id="login" class="login-panel panel panel-default"&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;form role="form" method="post" action="login.php"&gt;
                          &lt;fieldset&gt;
                              &lt;!--login form--&gt;
                          &lt;/fieldset&gt;
                          &lt;?php if (isset($not_registered_error)) {
                              echo "&lt;div class=\"alert alert-danger\" role=\"alert\"&gt;" . $not_registered_error . "&lt;/div&gt;";
                          }
                          if (isset($wrong_password_error)) {
                              echo "&lt;div class=\"alert alert-danger\" role=\"alert\"&gt;" . $wrong_password_error . "&lt;/div&gt;";
                          } ?&gt;
                          &lt;p&gt;Haven't joined yet? &lt;a href="signup.php"&gt;Sign up&lt;/a&gt;.&lt;/p&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  //...
  </code></pre>
  
  <p>Unlike most examples I found on the web, what I am trying to accomplish here is to have the program to figure out whether the username (or email) doesn't exists or the password for that username is wrong.
  The sign up program I wrote works just great. The question itself is already long enough so I didn't add signup.php. Let me know if it can be helpful.
  Using mysql for a local database and Bootstrap for the styling.</p>
  
  <p>I know that this question won't be helpful for many as it is being asked, but I did't know how to formulate it better.</p>
  
  <p>Thank you all :D</p>