Java – user registration page not verified
•
Java
<?PHP
<?PHP $name = $_POST["name"]; $age = $_POST["age"]; $email = $_POST["email"]; $password =$_POST["password"]; $statement = MysqLi_prepare($db,"INSERT INTO user_info(name,age,email,password) VALUES (?,?,?)"); MysqLi_stmt_bind_param($statement,"siss",$name,$age,$email,$password); MysqLi_stmt_execute($statement); if($statement>0){ $response["success"] = 1; } else{ $response["success"] = 0; } echo json_encode($response); ?>
My user registration page does not want to be verified Please advise which side of the encoding between the PHP text file and the Android side will allow authentication Please help further, this is the code
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); final EditText Name = (EditText) findViewById(R.id.edtName); final EditText Age = (EditText) findViewById(R.id.edtAge); final EditText Email = (EditText) findViewById(R.id.edtUsername); final EditText Password = (EditText) findViewById(R.id.edtPassword); final ImageButton validate = (ImageButton) findViewById(R.id.btnReg); validate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final int age = Integer.parseInt(Age.getText().toString()); final String name = Name.getText().toString(); final String email = Email.getText().toString(); final String password = Password.getText().toString(); Name.setText(""); Age.setText(""); Email.setText(""); Password.setText(""); Response.Listener<String>responseListener=new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jsonResponse = new JSONObject(response); boolean success = jsonResponse.getBoolean("success"); if (success) { Intent intent = new Intent(Register.this,Login.class); Register.this.startActivity(intent); } else { AlertDialog.Builder builder = new AlertDialog.Builder(Register.this); builder.setMessage("Register Failed") .setNegativeButton("Retry",null) .create() .show(); } } catch (JSONException e) { e.printStackTrace(); } } }; RegisterRequest registerRequest = new RegisterRequest(name,password,responseListener); RequestQueue queue = Volley.newRequestQueue(Register.this); queue.add(registerRequest); } }); } public void extBtn(View view) { Intent intent = new Intent(this,MainActivity.class); startActivity(intent); } }
Solution
Try this Code:
$bind = MysqLi_stmt_bind_param($statement,$password); $execute = $bind->MysqLi_stmt_execute($bind); if(count($execute) > 0){ $response["success"] = 1; } else{ $response["success"] = 0; } echo json_encode($response);
Counting is the calculation of rows in a database
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码