title: Trying to authenticate email and password with localhost database
body: <p>Hi I have been trying to create a authentication login for my phonegap mobile application however when testing on my web browser, when I enter the values for email and password (exact same as those stored on localhost database) in the login form I always receive an alert saying alert 'You have entered the wrong Email and Password'.</p>
  
  <p>I have a strong feeling that it has something to do with my login.js file</p>
  
  <pre><code>$(function(){
      $('form').submit(function(){
  
      if(validateEmail() &amp;&amp; validateUserPassword())
      {
      $.post('libs/auth.php',$('form').serialize(),function(response){
      if(response == 'true')
      {
      alert('You Have logged in successfully');
      setTimeout(function(){
          $.mobile.changePage('index.php', { transition: "slide"});
          },2000);
      }
      else
      {
      alert('You have entered the wrong Email and Password');
      }
      });
      }
  
      validateEmail();
      function validateEmail(){
      if($('#email').val().length == 0)
      {
      alert('Email is empty');
      return false;
      }
      else
      {
      return true;
      }
  
  
      }
      validateUserPassword();
      function validateUserPassword(){
      if($('#password').val().length == 0)
      {
      alert('Password is empty');
      return false;
      }
      else
      {
      return true;
      }
  
      }
  
  
  
      })
  })
  </code></pre>
  
  <p>Just in case this isn't the problem I will include the various other relevant pieces of code:</p>
  
  <p>Login Button from login.php</p>
  
  <pre><code>&lt;div id="loginButtonDiv" data-role="field-contain"&gt;
      &lt;button name="login" type="submit" data-inline="true"&gt;Log-In&lt;/button&gt;
      &lt;/div&gt; &lt;!-- End login button div --&gt;
  </code></pre>
  
  <p>Database Class (class.database.php)</p>
  
  <pre><code>&lt;?php
  
      class ManageDatabase{
  
      protected $db_conn;
      protected $db_host = 'localhost';
      protected $db_name = 'users';
      protected $db_user = 'root';
      protected $db_pass = '';
  
      function connect(){
          try{
              $this-&gt;db_conn = new PDO("mysql:host=$this-&gt;db_host;dbname=$this-&gt;db_name",$this-&gt;db_user,$this-&gt;db_pass);
              return $this-&gt;db_conn;
  
  
          }
          catch(PDOException $e){
                  return $e-&gt;getMessage();
  
          }
  
          }
      }
  
  
  ?&gt;
  </code></pre>
  
  <p>class.manageUsers.php</p>
  
  <pre><code>&lt;?php
  
      include_once( 'class.database.php' );
  
  
      class ManageUsers{
          protected $link;    
          function __construct(){
  
          $db_conn = new ManageDatabase;
          $this-&gt;link = $db_conn-&gt;connect();
          return $this-&gt;link;
  
  }
  function loginUsers($email,$password)
          {
          $query = $this-&gt;link-&gt;query("SELECT * FROM users WHERE email = '$email' AND password = '$password' LIMIT 1");
          $rowCount = $query-&gt;rowCount();
          return $rowCount;
  
          }
  }
  
  ?&gt;
  </code></pre>
  
  <p>auth.php file</p>
  
  <pre><code>&lt;?php
      if($_POST)
      {
  
      include_once( '../core/class.manageUsers.php' );
  
      $email = trim($_POST['email']);
      $password = trim($_POST['password']);
  
      if(empty($email) &amp;&amp; empty($password))
      {
          echo 'All fields are required';
          }
          else{
              $password = md5($password);
              $init = new ManageUsers;
              $login = $init-&gt;loginUsers($email,$password);
  
              if($login == 1)
              {
              echo 'true';
  
              }
              else{
              echo 'invalid credentials';
              }
  }
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>Any help with solving this problem would be greatly appreciated!</p>