title: JSON data cannot be retrieved in android from php
body: <p>I want to get the details of the user who has logged in.
  I am getting null or no value in the alert dialog (var - name)</p>
  
  <p>I am new to everything so I am sorry if the question is not worth it, I have tried finding the solutions but no luck yet so please help.</p>
  
  <p><a href="https://i.stack.imgur.com/m6Efs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m6Efs.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/9Fz34.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Fz34.png" alt="enter image description here"></a></p>
  
  <pre><code>if (type.equals("linkuser")) {
          try {
              URL url = new URL(Link_url);
              HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
              httpURLConnection.setRequestMethod("POST");
              httpURLConnection.setDoOutput(true);
              httpURLConnection.setDoInput(true);
              OutputStream outputStream = httpURLConnection.getOutputStream();
              BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
              String post_data = URLEncoder.encode("user", "UTF-8") + "=" + URLEncoder.encode(user, "UTF-8");
              bufferedWriter.write(post_data);
              bufferedWriter.flush();
              bufferedWriter.close();
              outputStream.close();
              InputStream inputStream = httpURLConnection.getInputStream();
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
              String result = "";
              String line = "";
              while ((line = bufferedReader.readLine()) != null) {
                  result += line;
              }
              bufferedReader.close();
              inputStream.close();
              httpURLConnection.disconnect();
              return result;
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  </code></pre>