JAVA json php Register quits without error does not store details in database

I am trying to store user details in phpmyadmin database using php script. Everything works fine but saving done without logs and errors. Here is codes:

Register java

public void onClick(View v) {
        int selected = rgb.getCheckedRadioButtonId();
        radio = (RadioButton) findViewById(selected);
        switch (v.getId()) {
            case R.id.bRegister:
                String vardas = etVardas.getText().toString();
                String pavarde = etPavarde.getText().toString();
                String amziaus_grupe = radio.getText().toString();
                String elpastas = etElpastas.getText().toString();
                String slaptazodis = (etSlaptazodis.getText().toString());
                User user = new User(vardas, pavarde,amziaus_grupe ,elpastas, slaptazodis);
                registerUser(user);
                break;
        }
    }

    private void registerUser(User user) {
        ServerRequests serverRequest = new ServerRequests(this);
        serverRequest.storeUserDataInBackground(user, new GetUserCallback() {
            @Override
            public void done(User returnedUser) {
                Intent loginIntent = new Intent(Register.this, Login.class);
                startActivity(loginIntent);
            }
        });
    }
}

ServerRequest

public void storeUserDataInBackground(User user,
                                          GetUserCallback userCallBack) {
        progressDialog.show();
        new StoreUserDataAsyncTask(user, userCallBack).execute();
    }



public class StoreUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
        User user;
        GetUserCallback userCallBack;

        public StoreUserDataAsyncTask(User user, GetUserCallback userCallBack) {
            this.user = user;
            this.userCallBack = userCallBack;
        }

        @Override
        protected Void doInBackground(Void... params) {
            ArrayList<NameValuePair> dataToSend = new ArrayList<>();
            dataToSend.add(new BasicNameValuePair("vardas", user.vardas));
            dataToSend.add(new BasicNameValuePair("pavarde", user.pavarde));
            dataToSend.add(new BasicNameValuePair("amziaus_grupe", user.amziaus_grupe));
            dataToSend.add(new BasicNameValuePair("dlpastas", user.elpastas));
            dataToSend.add(new BasicNameValuePair("slaptazodis", user.slaptazodis));
            HttpParams httpRequestParams = getHttpRequestParams();

            HttpClient client = new DefaultHttpClient(httpRequestParams);
            HttpPost post = new HttpPost(SERVER_ADDRESS
                    + "Register.php");

            try {
                post.setEntity(new UrlEncodedFormEntity(dataToSend));
                client.execute(post);
            } catch (Exception e) {
                e.printStackTrace();
            }

            return null;
        }

        private HttpParams getHttpRequestParams() {
            HttpParams httpRequestParams = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpRequestParams,
                    CONNECTION_TIMEOUT);
            HttpConnectionParams.setSoTimeout(httpRequestParams,
                    CONNECTION_TIMEOUT);
            return httpRequestParams;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            progressDialog.dismiss();
            userCallBack.done(null);
        }

    }

User class

public class User {

    String vardas, pavarde,amziaus_grupe , slaptazodis, elpastas;

    public User(String vardas, String pavarde, String amziaus_grupe, String elpastas, String slaptazodis) {
        this.vardas = vardas;
        this.pavarde = pavarde;
        this.amziaus_grupe = amziaus_grupe;
        this.slaptazodis = slaptazodis;
        this.elpastas = elpastas;
    }

    public User(String elpastas, String slaptazodis) {
        this("", "","", elpastas, slaptazodis);
    }
}

register php

<?php
    $con=mysqli_connect("mysql10.000webhost.com","a6287219_login","killeris11","a6287219_login");

    $vardas= $_POST["Vardas"];
    $pavarde= $_POST["Pavarde"];
    $amziaus_grupe= $_POST["Amziaus_grupe"];
    $elpastas= $_POST["El_pastas"];
    $slaptazodis= $_POST["Slaptazodis"];

    $statement = mysqli_prepare($con, "INSERT INTO Vartotojas(Vardas, Pavarde, Amziaus_grupe, El_pastas, Slaptazodis) VALUES (?, ?, ?, ?, ?)");
    mysqli_stmt_bind_param($statement, "sssss", $vardas, $pavarde, $amziaus_grupe, $elpastas, $slaptazodis);
    mysqli_stmt_execute($statement);

    mysqli_stmt_close($statement);

    mysqli_close($con);
?>

Logcat

05-26 11:27:46.052  19435-19435/com.tonikamitv.loginregister D/OpenGLRenderer﹕ Enabling debug mode 0
05-26 11:27:48.132  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
05-26 11:27:48.162  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ setComposingText on inactive InputConnection
05-26 11:27:48.192  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getExtractedText on inactive InputConnection
05-26 11:27:53.002  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
05-26 11:27:53.002  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ setComposingText on inactive InputConnection
05-26 11:27:53.002  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getExtractedText on inactive InputConnection
05-26 11:27:55.052  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
05-26 11:27:55.082  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ setComposingText on inactive InputConnection
05-26 11:27:55.082  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getExtractedText on inactive InputConnection
05-26 11:27:59.432  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
05-26 11:27:59.432  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ setComposingText on inactive InputConnection
05-26 11:27:59.432  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getExtractedText on inactive InputConnection
05-26 11:28:03.822  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
05-26 11:28:03.852  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ setComposingText on inactive InputConnection
05-26 11:28:03.852  19435-19435/com.tonikamitv.loginregister W/IInputConnectionWrapper﹕ getExtractedText on inactive InputConnection


Source: java

Leave a Reply