title: Log-in Only Works When Submit button is clicked Twice
body: <p>Please I need your help with this log-in script. When a user registers, a column <code>active</code> in the database is set to zero (0), and an activation link is sent to the email they provided. When the activation link is clicked and if successful, their respective <code>active</code> column is set to 1.</p>
  
  <p>But a correct combination of username and password only works when i click the submit button twice.</p>
  
  <p>On the first click i get the following lines</p>
  
  <p><strong>Notice: Undefined index: remember in C:\wamp\www\church\login.php on line 37</strong></p>
  
  <p><strong>Not Verified Yet</strong>  </p>
  
  <p>But when I click the second time the log-in works.  </p>
  
  <pre><code>&lt;?php
  if (isset($_POST['submit'])) {
      $username = trim($_POST['username']);
      $username = strip_tags($_POST['username']);
      $username = htmlentities($_POST['username']);
      $username = stripslashes($_POST['username']);
      $username = mysql_real_escape_string($_POST['username']);
      $password = sha1($_POST['password']);
  
      if (isset($_POST['username']) &amp;&amp; isset($_POST['password'])) {
          $query = mysql_query("SELECT username, password
                             FROM USERS
                             WHERE username = '$username'
                             AND password = '$password'") or die (mysql_error());
  
          $user = mysql_num_rows($query);
          if ($user == 1) {
              $row = mysql_fetch_assoc($query);
              if ($row['active'] == 1) {
                  $_SESSION['logged_username'] = $username;
                  if ($_POST['remember']) {
                      setcookie("CookieUser", $_SESSION['logged_username'], time() + 60 * 60 * 24 * 100, "/");
                      setcookie("CookiePass", $password, time() + 60 * 60 * 24 * 100, "/");
  
                      header('Location: http://127.0.0.1/church/index.php?id=1');
                  }
              }
              if ($row['active'] !== 1) {
                  echo "Not Verified Yet";
              }
          }
          else {
              echo "&lt;div id='content' &gt;";
              echo "&lt;div class='OpenError' &gt;";
              echo "Username &amp; Password Combination Is Wrong";
              echo "&lt;/div&gt;";
              echo "&lt;/div&gt;";
  
          }
      }
  }
  ?&gt;
  </code></pre>