i have tried to use json objectRequest and i was unable to post the data to the php file that i have provide below
reg=regno.getText().toString().trim();
psw=password.getText().toString().trim();
JSONObject postparams=new JSONObject();
try {
postparams.put("reg",reg);
postparams.put("password",psw);
} catch (JSONException e) {
e.printStackTrace();
}
JsonObjectRequest jor=new JsonObjectRequest(Request.Method.POST, url,postparams , new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
int resultCode=response.getInt("resultCode");
switch (resultCode){
case 1:
Toast.makeText(getApplicationContext(),response.getString("responseDesc"),Toast.LENGTH_SHORT).show();
Intent i=new Intent(getApplicationContext(),TabLayout.class);
startActivity(i);
break;
default:
Toast.makeText(getApplicationContext(),"Unkown error",Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),error.getMessage(),Toast.LENGTH_SHORT).show();
}
});
Mysigleton.getInstance(getApplicationContext()).addRequest(jor);
below is the php code where i want my params to get posted $login=new loginApi($_POST['reg'],$_POST['password']);