使用 volley stringreuqest 时未发送 POST 数据

我仍然是 android 应用程序开发的新手,并且这个问题已经存在很长时间了。我正在尝试创建一个注册页面,但未发送发布数据。这是我的代码:


注册活动


public class RegisterActivity extends AppCompatActivity {


    private EditText name, email, password, c_password;

    private Button register_button;

    private ProgressBar loading;

    private static String URL_REGIST = "http://192.168.1.6:7777/androidregistertest/register.php";


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_register);


        loading = findViewById(R.id.loading);

        name = findViewById(R.id.name);

        email = findViewById(R.id.email);

        password = findViewById(R.id.password);

        c_password = findViewById(R.id.c_password);

        register_button = findViewById(R.id.register_button);


        register_button.setOnClickListener(new View.OnClickListener(){


            @Override

            public void onClick(View view) {

                Regist();

            }

        });

    }


当我单击注册按钮时,响应包含以下错误消息,


通知:未定义指数:名称中d:\ XAMPP-7 \ htdocs中\ androidregistertest \ register.php上线3

通知:未定义指数:电子邮件中d:\ XAMPP-7 \ htdocs中\ androidregistertest \ register.php线4

通知:未定义索引:密码在D:\xampp-7\htdocs\androidregistertest\register.php第5行

为什么不发送post数据?


HUX布斯
浏览 139回答 1
1回答

波斯汪

除了一件事之外,一切似乎都是正确的,即您已将参数添加到 Map 但没有将其返回给 volly 以发送它。您的方法需要一行更改@Override&nbsp; &nbsp; &nbsp; &nbsp; protected Map<String, String> getParams() throws AuthFailureError {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<String, String> params = new HashMap<>();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.put("name", name);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.put("email", email);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.put("password", password);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return super.getParams(); //Change this&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return params; //to this&nbsp; &nbsp; &nbsp; &nbsp; }最好的祝愿。
打开App,查看更多内容
随时随地看视频慕课网APP