0

hi guys i have an error in my code wish you can help me with it to learn more from you , my php page and databse is ready and connected, but when im trying to register in my app i see this erorr

activity:

EditText name, email, password, password2;
Button bt1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);
    name = (EditText) findViewById(R.id.ed1);
    email = (EditText) findViewById(R.id.ed2);
    password = (EditText) findViewById(R.id.ed3);
    password2 = (EditText) findViewById(R.id.ed4);
    bt1 = (Button) findViewById(R.id.bt1);

    bt1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            String Ename = name.getText().toString().trim();
            String Email = email.getText().toString().trim();
            String Pass = password.getText().toString().trim();
            String Pass2 = password2.getText().toString().trim();

            if (!Pass.equals(Pass2)) {
                Toast.makeText(Registration.this, "Password doesnt match!", Toast.LENGTH_SHORT).show();
            } else {
                Response.Listener<String> responseLisener = new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonRespone = new JSONObject(response);
                            boolean success = jsonRespone.getBoolean("success");
                            if (success) {
                                Toast.makeText(Registration.this, "Registartion Complete!", Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(Registration.this, "Something wen wrong, Registration uncompleted", Toast.LENGTH_SHORT).show();
                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                };
                Send_Data_Registration send_Data = new Send_Data_Registration(Ename, Email, Pass, responseLisener);
                RequestQueue queue = Volley.newRequestQueue(Registration.this);
                queue.add(send_Data);

            }
        }
    });


}

}

and this is the class Send_Data_Registartion

public class Send_Data_Registration extends StringRequest {

    private static final String SEND_DATA_URL = "http://dev-redakhalaf.000webhostapp.com/Registration.php";
    private Map<String,String>MapData;

    public Send_Data_Registration(String name , String email, String password, Response.Listener<String> listener){
            super(Method.POST,SEND_DATA_URL, listener,null);
            MapData = new HashMap<>();
            MapData.put("ename",name);
            MapData.put("email",email);
            MapData.put("epassword",password);

    }

    @Override
    protected Map<String, String> getParams()  {
        return MapData;
    }
}

this is the erorr:

W/System.err: org.json.JSONException: Value <? of type java.lang.String cannot be converted to JSONObject
W/System.err:     at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err:     at org.json.JSONObject.<init>(JSONObject.java:163)
W/System.err:     at org.json.JSONObject.<init>(JSONObject.java:176)
W/System.err:     at com.example.redakhalaf.lessons.Registration$1$1.onResponse(Registration.java:49)
W/System.err:     at com.example.redakhalaf.lessons.Registration$1$1.onResponse(Registration.java:45)
W/System.err:     at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
W/System.err:     at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
W/System.err:     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
W/System.err:     at android.os.Handler.handleCallback(Handler.java:789)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:98)
W/System.err:     at android.os.Looper.loop(Looper.java:164)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6541)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Shadow
  • 33,525
  • 10
  • 51
  • 64
  • Possible duplicate of [What is a stack trace, and how can I use it to debug my application errors?](https://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors) – rghome Dec 24 '17 at 12:59
  • 1
    The server appears to be serving this file http://dev-redakhalaf.000webhostapp.com/Registration.php as static content (like html) instead of executing the php. The response a POST to that address is the php source, not a response that can be JSON'ized. – F Rowe Dec 24 '17 at 13:11

0 Answers0