I am working on an Android app in which I am submitting some variables in url in order to save the data in database what ever user enter in the text fileds but I am unable to do so as I am getting an error called "com.android.volley,Server error". I have tried many solutions on stack overflow like use a variable in a URL object in android and the other one Volley server error with null network response bit it didn't solved my problem. Here is my sample code for registering url
Context context;
EditText username, address, phoneNumber;
Button location, save;
String macAddress;
private final String REGISTER_URL = "http://www.zamakpk.com/sos/index.php/webservices_api/insert_user"+username+address+macAddress+phoneNumber;
public static final String KEY_USERNAME = "name";
public static final String KEY_Address = "address";
public static final String KEY_PHONENO = "mobile";
public static final String KEY_MAC_ADDRESS = "mac";
//And this is how I am registeing a user//
private void registerUser() {
final String usernameStr = username.getText().toString().trim();
final String addressStr = address.getText().toString().trim();
final String phoneNoStr = phoneNumber.getText().toString().trim();
StringRequest stringRequest = new StringRequest(Request.Method.POST, REGISTER_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, response, Toast.LENGTH_LONG).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_LONG).show();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put(KEY_MAC_ADDRESS, macAddress);
params.put(KEY_USERNAME, usernameStr);
params.put(KEY_PHONENO, phoneNoStr);
params.put(KEY_Address, addressStr);
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
Any idea what I am missing that I am unable to store user data in database and my server is working fine its working good on localhost. Any help would be much appreciated thanks