title: HTTP request is returning null object
body: <p>My code is just throwing back a null object from the server, I don't know if its the way I am trying to grab the info or I don't even know. Anything obvious you can see?</p>
  
  <pre><code>static InputStream is = null;
  static JSONObject jObj = null;
  static String json = "";
  
  // constructor
  public JSONParser() {
  
  }
  
   // function get json from url
      // by making HTTP POST or GET mehtod
      public JSONObject makeHttpRequest(String url, String method,
                                        List&lt;NameValuePair&gt; params) {
  
          // Making HTTP request
          try {
  
              // check for request method
              if(method == "POST"){
                  // request method is POST
                  // defaultHttpClient
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  HttpPost httpPost = new HttpPost(url);
                  httpPost.setEntity(new UrlEncodedFormEntity(params));
  
                  HttpResponse httpResponse = httpClient.execute(httpPost);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
  
                  Log.e("Zam", httpEntity.toString());
              }else if(method == "GET"){
                  // request method is GET
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  String paramString = URLEncodedUtils.format(params, "utf-8");
                  url += "?" + paramString;
                  HttpGet httpGet = new HttpGet(url);
  
                  HttpResponse httpResponse = httpClient.execute(httpGet);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
              }
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              json = sb.toString();
          } catch (Exception e) {
              //Log.e("Zam", "Error converting result " + e.toString());
          }
  
          // try parse the string to a JSON object
          try {
              jObj = new JSONObject(json);
          } catch (JSONException e) {
              //Log.e("Zam", "Error parsing data " + e.toString());
          }
  
          // return JSON String
          return jObj;
  
      }
  </code></pre>
  
  <p>here is where im calling it from </p>
  
  <pre><code> class AttemptLogin extends AsyncTask&lt;String, String, String&gt;{
  
      boolean failure = false;
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          pDialog = new ProgressDialog(LogInActivity.this);
          pDialog.setMessage("Attempting to log you in");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(true);
          //pDialog.show();
      }
  
      @Override
      protected String doInBackground(String... args) {
  
          int success;
          String email = emailET.getText().toString();
          String pass = passwordET.getText().toString();
  
          try {
              // Building Parameters
              List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
              params.add(new BasicNameValuePair("username", email));
              params.add(new BasicNameValuePair("password", pass));
  
              Log.d("request!", "starting");
              // getting product details by making HTTP request
              JSONObject json = jsonParser.makeHttpRequest(
                      LOGIN_URL, "POST", params);
  
              // check your log for json response
              Log.d("Login attempt", json.toString());
  
              // json success tag
              success = json.getInt(TAG_SUCCESS);
              if (success == 1) {
                  Log.d("Login Successful!", json.toString());
                  Intent i = new Intent(LogInActivity.this, MainActivity.class);
                  finish();
                  startActivity(i);
                  return json.getString(TAG_MESSAGE);
              }else{
                  Log.d("Login Failure!", json.getString(TAG_MESSAGE));
                  return json.getString(TAG_MESSAGE);
  
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
  
          return null;
      }
  
      @Override
      protected void onPostExecute(String file_url) {
          pDialog.dismiss();
          if(file_url != null){
              Toast.makeText(LogInActivity.this, file_url, Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>
  
  <p>Server side </p>
  
  <pre><code>    &lt;?php
  
  require("config.inc.php");
  
  if(!empty($_POST)){
  
      $query = "
        SELECT
          email
          password
          From users
          WHERE email = :email
      ";
  
      $queryParams = array(
          ':email' =&gt; $_POST['email']
      );
  
      try{
  
          $stmt = $db-&gt;prepare($query);
          $result = $stmt-&gt;execute($queryParams);
  
      }catch (PDOException $ec){
          $response["success"] = 0;
          $response["message"] = "Database Error1. unknown email address!";
          die(json_encode($response));
  
      }
  
      $row = $stmt-&gt;fetch();
      $loginOk = false;
  
  
      if($row){
  
          if($_POST['password'] === $row['password']){
              $loginOk = true;
          }
  
      }
  
      if($loginOk ===  true){
          $response["success"] = 1;
          $response["message"] = "logged in";
          die(json_encode($response));
      } else{
          $response["success"] = 0;
          $response["message"] = "wrong password";
          die(json_encode($response));
      }
  
  }else{
  ?&gt;
      &lt;h1&gt;Login&lt;/h1&gt;
  
      &lt;form action="login.php" method="post"&gt;
  
          Email:&lt;br /&gt;
  
          &lt;input type="text" name="email" placeholder="email" /&gt;
  
          &lt;br /&gt;&lt;br /&gt;
  
          Password:&lt;br /&gt;
  
          &lt;input type="password" name="password" placeholder="password" value="" /&gt;
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;input type="submit" value="Login" /&gt;
  
      &lt;/form&gt;
  
      &lt;a href="register.php"&gt;Register&lt;/a&gt;
  
  &lt;?php
  
  }
  </code></pre>