title: Android Login- checking if username and password match with MySQL database
body: <p>I am working on an android app and kinda new in app development. PHP and MySQL are being used for backend. I am building the login page and I want to check if username and password match with database after JSON parsing. I have already parsed JSON and now only the check part is left. I feel like I should make a list and query it using a foreach loop, but I don't know how. Any suggestions or code example would be greatly appreciated! Here is my login and onPostExecute method-</p>
  
  <pre><code>public void login(View view) {
  
      Log.i("username", userNameField.getText().toString());
      Log.i("password", passwordField.getText().toString());
  
      DownloadTask task = new DownloadTask();
      task.execute("http://something.com.php");
  
  
  }
  
  @Override
      protected void onPostExecute(String result) {
          super.onPostExecute(result);
  
          Log.i("Website Content", result);
  
          try {
  
  
             JSONArray arr = new JSONArray(result);
  
            for (int i = 0; i &lt; arr.length(); i++) {
  
                JSONObject jsonPart = arr.getJSONObject(i);
  
           Log.i("user", jsonPart.getString("email"));
           Log.i("pass", jsonPart.getString("password"));
  
                dbUserName= jsonPart.getString("email");
                dbPassword= jsonPart.getString("password");
  
           // if ((userName == dbUserName) &amp;&amp; (password == (dbPassword))){
  
             //  Log.i("AppInfo", "Login Successful!");
  
          //   }
           // else{
           //   Log.i("Appinfo", "you suck");
           //   }
  
            } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  </code></pre>