I'm trying to make a login, using a BD but when I tap the button, the app does not do anything, I hope you can help me thanks.
Error:
2018-12-30 01:17:44.741 12905-8164/? W/fb4a.1ix: GraphQL Subscription over MQTT got unexpected payload on pattern /graphql/3/graphqlsubscriptions/0/315301209301124/{"use_deprecated_can_viewer_like":true,"input":{"feedback_id":"ZmVlZGJhY2s6MjIzODkzODM1MzA1NzQwNw==","client_subscription_id":"baac4a87-f293-4d3d-8e75-dd84f7bc0fca"},"profile_image_size":120,"enable_comment_reactions":true,"enable_comment_reactions_icons":true,"enable_ranked_replies":"true","enable_private_reply":true,"enable_comment_replies_most_recent":"true","max_comment_replies":3,"enable_comment_shares":true}
2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: org.json.JSONException: Value (JSONObject.java:160) 2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: at org.json.JSONObject. (JSONObject.java:173) 2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: at com.example.brian.login.Login $ 2 $ 1.onResponse (Login.java:61) 2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: at com.example.brian.login.Login $ 2 $ 1.onResponse (Login.java:57) 2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: at com.android.volley.toolbox.StringRequest.deliverResponse (StringRequest.java:78) 2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: at com.android.volley.toolbox.StringRequest.deliverResponse (StringRequest.java30) 2018-12-30 01: 17: 45.207 6633-6633 / com.example.brian.login W / System.err: at com.android.volley.ExecutorDelivery $ ResponseDeliveryRunnable.run (ExecutorDelivery.java:106) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at android.os.Handler.handleCallback (Handler.java:751) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at android.os.Handler.dispatchMessage (Handler.java:95) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at android.os.Looper.loop (Looper.java:241) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at android.app.ActivityThread.main (ActivityThread.java:6274) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at java.lang.reflect.Method.invoke (Native Method) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:886) 2018-12-30 01: 17: 45.208 6633-6633 / com.example.brian.login W / System.err: at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776) 2018-12-30 01: 17: 49.386 8171-8171 /? W / System: ClassLoader referenced unknown path: /data/app/com.sonymobile.getmore-2/lib/arm64 2018-12-30 01: 17: 50.544 2201-2970 /? W / AppOps: Bad call: specified package com.google.android.gms under uid 10314 but it is really 10057
code:
public class Registro extends AppCompatActivity implements View.OnClickListener {
EditText etnombre, etapellidos,etusuario, etcertificacion, etcontrasena;
Button aceptar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registro);
etnombre = findViewById(R.id.nom);
etapellidos = findViewById(R.id.ape);
etusuario = findViewById(R.id.usr);
etcertificacion = findViewById(R.id.cert);
etcontrasena = findViewById(R.id.contra);
aceptar= findViewById(R.id.aceptar);
aceptar.setOnClickListener(this);
}
@Override
public void onClick(View view) {
final String name=etnombre.getText().toString();
final String surname=etapellidos.getText().toString();
final String user_name=etusuario.getText().toString();
final String course=etcertificacion.getText().toString();
final String password=etcontrasena.getText().toString();
Response.Listener<String> respoListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success){ /*si el registro es exitoso nos envia a la pagina principal*/
Intent intent = new Intent(Registro.this,Login.class);
Registro.this.startActivity(intent);
}else{
AlertDialog.Builder builder = new AlertDialog.Builder(Registro.this);
builder.setMessage("ERROR EN EL REGISTRO")
.setNegativeButton("Retry",null)
.create().show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
SolicitudDeRegistro solicitudDeRegistro = new SolicitudDeRegistro(name, surname, user_name, course, password, respoListener);
RequestQueue queue = Volley.newRequestQueue(Registro.this);
queue.add(solicitudDeRegistro);
}
}
Connection file with the BD pchp.:
<?php
$con = mysqli_connect("localhost", "root", "", "usuarios");
$user_name = $_POST["user_name"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM usuarios WHERE user_name = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $user_name, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement,$name,$surname, $user_name, $course,$password);
$response = array();
$response["success"] = true;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["name"] = $name;
$response["surname"] = $surname;
$response["user_name"] = $user_name;
$response["course"] = $course;
$response["password"] = $password;
}
echo json_encode($response);
? >