Android截击向数据库发布空值

Android截击向数据库发布空值,android,android-volley,Android,Android Volley,我的应用程序应该向我的php脚本发送一些数据,php脚本反过来会将数据推送到我的在线数据库中。但该应用程序一直发送空值,并使用简单的HTML表单尝试了我的php脚本,它工作正常并发布到数据库 我还不熟悉使用截击库 这是我的注册课程: private void registerfunc(final String name, final String email, final String phone, final String address) {` String url ="http:

我的应用程序应该向我的php脚本发送一些数据,php脚本反过来会将数据推送到我的在线数据库中。但该应用程序一直发送空值,并使用简单的HTML表单尝试了我的php脚本,它工作正常并发布到数据库

我还不熟悉使用截击库

这是我的注册课程:

private void registerfunc(final String name, final String email, final String phone, final String address) {`

    String url ="http://circleincoprated.com/apps/register.php";

    StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d("JSon data... ", response);
                    if (response.trim().equals("success")) {
                        pd.hide();
                        Toast.makeText(first_run.this, "registration Successful", Toast.LENGTH_LONG).show();
                        Intent in = new Intent(first_run.this, MainActivity.class);
                        startActivity(in);
                    } else {
                        pd.hide();
                        Toast.makeText(first_run.this, "registration Failed" + response, Toast.LENGTH_LONG).show();

                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    pd.hide();
                    Log.d("JSon Error... ", error.toString());
                    Toast.makeText(first_run.this, error.toString(), Toast.LENGTH_LONG).show();

                }
            }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            //Creating parameters
            Map<String, String> params = new Hashtable<>();
            //Adding parameters
            params.put("name", name);
            params.put("phone", phone);
            params.put("email", email);
            params.put("address", address);


            //returning parameters
            return params;
        }
    };

    new MySingleton(first_run.this).addToRequestQueue(stringRequest);
}
private void registerfunc(最终字符串名称、最终字符串电子邮件、最终字符串电话、最终字符串地址){`
字符串url=”http://circleincoprated.com/apps/register.php";
StringRequest StringRequest=新的StringRequest(Request.Method.POST,url,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
Log.d(“JSon数据…”,响应);
if(response.trim().equals(“success”)){
pd.hide();
Toast.makeText(首次运行此“注册成功”,Toast.LENGTH.show();
Intent in=新Intent(首次运行this,MainActivity.class);
星触觉(in);
}否则{
pd.hide();
Toast.makeText(首次运行此“注册失败”+响应,Toast.LENGTH.show();
}
}
},
新的Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
pd.hide();
Log.d(“JSon错误…”,Error.toString());
Toast.makeText(first_run.this,error.toString(),Toast.LENGTH_LONG.show();
}
}) {
@凌驾
受保护的映射getParams()引发AuthFailureError{
//创建参数
Map params=新哈希表();
//添加参数
参数put(“名称”,名称);
参数put(“电话”,电话);
参数put(“电子邮件”,电子邮件);
参数put(“地址”,地址);
//返回参数
返回参数;
}
};
新建MySingleton(首次运行).addToRequestQueue(stringRequest);
}
这是我的php脚本:

<?php
 extract($_POST);
 if(isset($name)){
 $resp='';
    include 'config.php';
 $sql = "INSERT INTO users (id,name,phone,email,address)
  VALUES ('','".$name."', '".$phone."', '".$email."','".$address."')";

if ($conn->query($sql) === TRUE) {
 $resp="success";
    echo($resp);
 $sql = "INSERT INTO log (id,response) Values('','".$resp."')";
 $conn->query($sql);
 }else {
   $resp= "Error: " . $sql . "<br>" . $conn->error;
 $conn->query($sql);
 echo($resp);
}}else{
   echo "Empty data";
  }
?>