Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Parse JSON help

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 443
    Answer it

    This is my code Sometimes i dont get an empty string.

       
    EditText ord;
        TextView fintext;
        Button send;
        RequestQueue requestQueue;
        String insertUrl = "myurl";
    
     requestQueue = Volley.newRequestQueue(getActivity().getApplicationContext());
        send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StringRequest request = new StringRequest(Request.Method.POST, insertUrl, new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
    
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
    
                    }
                }) {
                    @Override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        Map<String, String> parameters = new HashMap<String, String>();
                        parameters.put("ord", ord.getText().toString());
    
                        return parameters;
                    }
                };
                requestQueue.add(request);
                Toast.makeText(getActivity(), "Tack, vi kontrollerar nu ordet.",
                        Toast.LENGTH&#95;SHORT).show();
                ord.setText("");
            }
    

    PHP file

    if($_SERVER["REQUEST_METHOD"]=="POST"){
        require 'connection.php';
        createStudent();
    }
    function createstudent()
    {
        global $connect;
    
    $firstname = $&#95;POST["ord"];
    
    
    $query = " Insert into charader(ord) values ('$firstname');";
    $query2 = " Insert into rita(ord) values ('$firstname');";
    
    
    mysqli&#95;query($connect, $query) or die (mysqli&#95;error($connect));
    mysqli&#95;query($connect, $query2) or die (mysqli&#95;error($connect));
    mysqli&#95;close($connect);
    

    }

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: