title: send object/var from php server to app android
body: <p>i have some trouble here with my server and app.. so i want to pass object/var from server with php..and i having trouble how to retrieve it.. in this case i want to pass id,username to my app..</p>
  
  <p>this is my code <strong>user.java</strong></p>
  
  <pre><code>public class User   {
     private String username="";  
     private String password="";  
     private int id;
  }
  </code></pre>
  
  <p>on my login form, this is my code </p>
  
  <pre><code>void login(){
      try{            
  
          httpclient=new DefaultHttpClient();
  
          httppost= new HttpPost("http://nervousme.vacau.com/check_login.php"); .
  
          nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
          side variable name and php side variable name should be similar, 
          nameValuePairs.add(new BasicNameValuePair("username",et_username.getText().toString().trim()));  
          nameValuePairs.add(new BasicNameValuePair("password",et_password.getText().toString().trim())); 
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
          response=httpclient.execute(httppost);
  
  
          ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
          final String response = httpclient.execute(httppost, responseHandler);
          System.out.println("Response : " + response); 
          runOnUiThread(new Runnable() {
              public void run() {
                  tv.setText("Response from PHP : " + response);
                  dialog.dismiss();
              }
          });
  
          if(response.equalsIgnoreCase("Login Berhasil")){
              runOnUiThread(new Runnable() {
                  public void run() {
                      Toast.makeText(LoginForm.this,"Login Berhasil", Toast.LENGTH_SHORT).show();
                  }
  
              });
  
              Intent intent = new Intent(LoginForm.this,UserHome.class);
              intent.putExtra("username",et_username.getText().toString());  
  
              startActivity(intent);
          }else{
              showAlert();                
          }
  
      }catch(Exception e){
          dialog.dismiss();
          System.out.println("Exception : " + e.getMessage());
      }
  }
  
  public void showAlert(){
      LoginForm.this.runOnUiThread(new Runnable() {
          public void run() {
              AlertDialog.Builder builder = new AlertDialog.Builder(LoginForm.this);
              builder.setTitle("Login Gagal");
              builder.setMessage("Terdapat Kesalahan Pada Username/Password")  
                     .setCancelable(false)
                     .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int id) {
                         }
                     });                     
              AlertDialog alert = builder.create();
              alert.show();               
          }
      });
  }
  </code></pre>
  
  <p>then on my php server side :</p>
  
  <pre><code>$query_search = "select * from USER where username = '".$username."'
  AND password = '".$password. "'";
  
  $query_exec = mysql_query($query_search) or die(mysql_error());
  
  $rows = mysql_num_rows($query_exec); //echo $rows;
  
  if($rows == 0) { 
    echo "Login Gagal";   
  }  else  {
    echo $username,$id;    
  }
  </code></pre>
  
  <p>is it my code on php server correct? (just echo username and id). if my code correct then how to save username and id to my object(class)? if i just echo username,id then show it to textview and get the value and set it on my class, is it still object oriented ?my friend make me confuse about object oriented programming</p>
  
  <p>any help will be appreciated..thanks..</p>