Click here to Skip to main content
14,879,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I was given assignment on android mysql http url connection. The assignment is as follows

Registering Users
Explanation: We would use this end point to register users by sending the following post keys
Usage: send these post keys
$_POST["register"] = 1 and $_POST['email']

I already have a code that i used for a project sometimes ago user registration, see code below

public class MainActivity extends AppCompatActivity {

    Button register , login ;
    EditText phone;
    String RegisterURL = "" ;
    Boolean CheckEditText ;
    String Response;
    HttpResponse response ;
    String EmailHolder;

    protected void onCreate(Bundle savedInstanceState) {

        register = (Button)findViewById(;
        login = (Button)findViewById(;

        phone = (EditText)findViewById(;
        phone.addTextChangedListener(new PhoneNumberFormattingTextWatcher());

        register.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {




                else {

                    Toast.makeText(MainActivity.this, "Please fill all form field.", Toast.LENGTH_LONG).show();



        login.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                Intent intent = new Intent(MainActivity.this, LoginActivity.class);


    public void GetCheckEditTextIsEmptyOrNot(){

        EmailHolder = phone.getText().toString();


            CheckEditText = false;

        else {

            CheckEditText = true ;


    public void SendDataToServer( final String phone){
        class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
            protected String doInBackground(String... params) {

                String QuickEmail = phone ;

                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

                nameValuePairs.add(new BasicNameValuePair("phone", QuickEmail));

                try {
                    HttpClient httpClient = new DefaultHttpClient();

                    HttpPost httpPost = new HttpPost(RegisterURL);

                    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    HttpResponse response = httpClient.execute(httpPost);

                    HttpEntity entity = response.getEntity();

                } catch (ClientProtocolException e) {

                } catch (IOException e) {

                return "Registration Successful, Login Now!!!";

            protected void onPostExecute(String result) {

                Toast.makeText(MainActivity.this, "Registration Successfully, Login Now!!!", Toast.LENGTH_LONG).show();

        SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();

My question is how can i use the information above i.e send these post keys $_POST["register"] = 1 and $_POST['email'] to register users in my app using the code i already have.
Thanks in advance

What I have tried:

have searched google and still asking friends
wseng 19-Jun-18 21:48pm
Well explanation

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900