Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:53:28+00:00 2026-06-17T18:53:28+00:00

I have been successful in creating an authentication using httppost from java Android code

  • 0

I have been successful in creating an authentication using httppost from java Android code through php to mysql. I’m having issues create a new user however. I’ve checked multiple posts from other users, and I think it looks good. Also, I’ve created a simple html form to test the php creation of new user, and that works too.

Any thoughts would be appreciated. Here is my java code and PHP below that. Thanks!

    try {
            // create new array list
            nameValuePairs = new ArrayList<NameValuePair>();

            // place them in an array list
            nameValuePairs.add(new BasicNameValuePair("username", user));
            nameValuePairs.add(new BasicNameValuePair("password", pass));

            // add array list to http post
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // assign executed form container to response
            response = httpclient.execute(httppost);

            // check status code,
            if (response.getStatusLine().getStatusCode() == 200) {
                // assign response entity to htpp entitiy
                entity = response.getEntity();

                // chekc if entity is not null
                if (entity != null) {

                    Log.i("RESPONSE",EntityUtils.toString(entity));

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

                    // }

                    // display a taost saying login was a success
                    Toast.makeText(CreateAccount.this, user,
                            Toast.LENGTH_SHORT).show();
                    // }

                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            // display toast when there is a connection error
            Toast.makeText(getBaseContext(), "ConnectionError",
                    Toast.LENGTH_SHORT).show();
        }

PHP Code:

    //get form data

$user = mysql_real_escape_string($_POST['user']);

$pass = mysql_real_escape_string($_POST['pass']);

echo "INSERT INTO androidlogin (user, pass) VALUES ('$user','$pass')";

//insert data
$insert = mysql_query("INSERT INTO androidlogin (user, pass) VALUES  ('$user','$pass')");
if($insert){
$arr2 = array("user" => $user, "pass" => $pass);
echo json_encode($arr2);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:53:29+00:00Added an answer on June 17, 2026 at 6:53 pm

    When posting values are called “username” and “password” whereas server checks for “user” & “pass”. You have to use the same keys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been successful in creating a tooltip for text using code similar to:
I have been successful in finding code for spawning a vim editor and creating
Im using JSoup with android and so far I have been successful. In my
I have been successful with creating a Telerik grid to display a list of
I have successfully been using Win32::Ole module to browser through pages and submit forms.
I have been successful in creating folder in Documents folder in iPhone simulator. NSError
I have been successful at rounding my value to one decimal point, but I
All these years i have been successfully using EnumServicesStatus in combination with OpenScManager (with
I have a Linq-To-Sql based repository class which I have been successfully using. I
I have successfully been using the eclipse Indigo internal browser to view my web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.