无法在android中使用volley登录和注册

时间:2017-11-20 10:16:50

标签: php android

我在android中使用volley进行登录和注册页面发布数据,我遇到了家庭活动无法启动的问题

这是android代码和php脚本

 StringRequest stringRequest = new StringRequest(Request.Method.POST, HttpUrl,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String ServerResponse) {

                    // Hiding the progress dialog after all task complete.
                    progressDialog.dismiss();

                    // Matching server responce message to our text.
                    if (ServerResponse.equalsIgnoreCase("Data Matched")) {


                        startActivity(new Intent(getApplicationContext(),HomeActivity.class));

                    }
                    else {

                        // Showing Echo Response Message Coming From Server.
                        Toast.makeText(LoginForm.this, ServerResponse, Toast.LENGTH_LONG).show();

                    }

                    // Finish the current Login activity.
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {

                    // Hiding the progress dialog after all task complete.
                    progressDialog.dismiss();

                    // Showing error message if something goes wrong.
                    Toast.makeText(LoginForm.this, volleyError.toString(), Toast.LENGTH_LONG).show();
                }
            }) {

这是处理来自Android应用程序的帖子的PHP代码

 <?php

 require "connection.php";
// Check whether username or password is set from android   
if($_SERVER['REQUEST_METHOD']=='POST'){


$username = $_POST['username'];
$password = $_POST['password'];

$Sql_Query = "select * from login_and_registration where username = 
'$username' and password = '$password'";

$check = mysqli_fetch_array(mysqli_query($conn,$Sql_Query));

if(isset($check)){

echo "Data Matched";
}
else{
echo "Invalid Username or Password Please Try Again !";
}

}else{
echo "Check Again";
}``
mysqli_close($conn);

?&gt; r code here

0 个答案:

没有答案