<?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); ?>
我的用户注册页面不想验证.请建议PHP文本文件和androID端之间编码的哪一方验证将允许验证.请进一步协助,这是代码.
@OverrIDeprotected 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() {@OverrIDepublic 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>() {@OverrIDepublic 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, age, email, 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);}}
解决方法:
尝试使用这部分代码:
$bind = MysqLi_stmt_bind_param($statement, "siss", $name, $age, $email, $password);$execute = $bind->MysqLi_stmt_execute($bind); if(count($execute) > 0){ $response["success"] = 1; } else{ $response["success"] = 0; } echo Json_encode($response);
计数是计算数据库中的行.
总结以上是内存溢出为你收集整理的java – 用户注册页面未验证全部内容,希望文章能够帮你解决java – 用户注册页面未验证所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)