title: Login returns password does not match in php
body: <p>I hope you are doing great. I have within my project a login functionality. when I try to login. It gives me this strange error that I did not write within my login.php script. I wrote it somewhere else and did not make an import to it. I hope you guys can help me identify the problem.
  <br />
  <br />Thanks in Advance. Cheers,
  <br />Some useful pieces of my code:
  <br />Login.php Script:</p>
  
  <pre><code>    &lt;?php
  include_once 'Header.php';
  ?&gt;
  &lt;style&gt;
      #container {
          height: 92vh;
      }
  &lt;/style&gt;
  &lt;div id="container"&gt;
      &lt;br&gt;
  
  
      &lt;?php
      $_SESSION['logged'] = null;
  
  //in this page we do things slightly differently - the code for validation and displaying messages is done
  //before we display the form 
      echo '&lt;div id = "div_1"&gt;&lt;h1&gt;Login&lt;/h1&gt;';
  
  //display the form
      echo '&lt;div id="div_2"&gt;&lt;div id="div_2"&gt;
         &lt;form action="Login.php" method="post"&gt;
             &lt;label&gt;Email&lt;br&gt;
             &lt;span class="small"&gt;enter your Email&lt;/span&gt;
             &lt;/label&gt;
             &lt;input type="text" name="Email" value=""/&gt;
             &lt;label&gt;&lt;br&gt;Password&lt;br&gt;
             &lt;span class="small"&gt;enter your password&lt;/span&gt;
             &lt;/label&gt;
             &lt;input type="password" name="Password" /&gt;
  
             &lt;button type="submit" name="submit" value="Login" /&gt;Log in&lt;/button&gt;
             &lt;input type ="hidden" name="submitted" value="1"&gt;
           &lt;/form&gt;
           &lt;/div&gt;
      &lt;/div&gt;';
  
      if (isset($_POST['submitted'])) {
          //require_once is similar to 'include' but ensures the code is not copied multiple times
          require_once('LoginFunctions.php');
          $name3 = $_POST['Email'];
          $pwd3 = $_POST['Password'];
          echo $name3;
          echo $pwd3;
          //list() is a way of assigning multiple values at the same time
          //checkLogin() function returns an array so list here assigns the values in the array to $check and $data
          list($check, $data) = checkLogin($_POST['Email'], $_POST['Password']);
  
  
          if ($check) {
              setcookie('FName', $data['FName'], time() + 900);  //cookie expires after 15 mins
              setcookie('LName', $data['LName'], time() + 900);
              //
              //use session variables instead of cookies
              //these variables should now be available to all pages in the application as long as the users session exists
              $_SESSION['FName'] = $data['FName'];
              $_SESSION['LName'] = $data['LName'];
              $_SESSION['Email'] = $data['Email'];
              //to enable $_SESSION array to be populated we always need to call start_session() - this is done in header.php
              //print_r is will print out the contents of an array
              print_r($_SESSION);
              //
              //Redirect to another page
              $url = absolute_url('Index.php');  //function defined in Loginfunctions.php to give absolute path for required page
              $_SESSION['logged'] = TRUE;
              echo $_SESSION['logged'];
              //this version of the header function is used to redirect to another page
              echo "&lt;script&gt;setTimeout(\"location.href = '" . $url . "';\",10000);&lt;/script&gt;"; //since we have entered correct login details we are now being directed to the home page
  
              exit();
          } else {
              $errors = $data;
          }
      }
  
      //create a sopace between the button and the error messages
      //echo'&lt;div class="spacer"&gt;&lt;/div&gt;';
  
      if (!empty($errors)) {
          echo '&lt;br/&gt; &lt;p class="error"&gt;The following errors occurred: &lt;br /&gt;';
  
          //foreach is a simplified version of the 'for' loop
          foreach ($errors as $err) {
              echo "$err &lt;br /&gt;";
          }
  
          echo '&lt;/p&gt;';
      }
  
      //this is the end of the &lt;div&gt; that contains the form
      echo '&lt;/div&gt;';
  
      /* */
      ?&gt;
  &lt;/div&gt;
  
  &lt;?php
  include 'Footer.php';
  ?&gt;
  </code></pre>
  
  <p>My loginFunctions.php class:</p>
  
  <pre><code>    &lt;?php
  
  
  function absolute_url($page = 'Index.php')
  {
      //header('Location: http:\\localhost');
      //exit(); //terminates the script
  
      $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
      $url = rtrim($url, '/\\');
      $url .= '/' . $page;
  
      return $url;
  }
  
  function checkLogin($Email = '', $password = '')
  {
    $errors = array();
  
    if(empty($Email))
      $errors[] = 'You must enter a Email';
  
    if(empty($password))
      $errors[] = 'You must enter a password';
  
    if(empty($errors))
    {
  ////set up database econnection
       include 'DBConn.php';
  
        $db = new DBConn();
        $dbc = $db-&gt;getDBConnection();
  
        $q = "select Email, FName, LName from Users_1 where Email = '$Email' and Password = '$password'";
  
        $r = mysqli_query($dbc, $q);
  
        if($r)
        {
            if(mysqli_affected_rows($dbc) != 0)
            {
              $row = mysqli_fetch_array($r, MYSQLI_ASSOC);
              return array(true, $row);
            }
            else
            {
              $errors[] = 'Passwords do not match';
            }
        }
        else{
          echo '&lt;p class="error"&gt; Oh dear. There was a database error&lt;/p&gt;';
          echo '&lt;p class = "error"&gt;' . mysqli_error($dbc) .'&lt;/p&gt;';
        }
  
    }
  
    return array(false, $errors);
  }
  ?&gt;
  </code></pre>