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 8112231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:25:01+00:00 2026-06-06T02:25:01+00:00

I am developing a small application and for that authentication is needed. That I’m

  • 0

I am developing a small application and for that authentication is needed. That I’m trying to develop by connecting to MYsql db through php.

add uname/pw –> loging –> send to php –> check db –> ok sends back to android –> authenticated. / error sends back to re loging.

I have developed so far, I think this is how it should be but I’m NOT sure since I’m really new to the cording.
Please be kind enough to help me with cording. Thank you.

public class Loging extends Activity{

    TextView txt;
    EditText uname,pwd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.loging);
        Button b = (Button)findViewById(R.id.log);
        uname = (EditText)findViewById(R.id.uname);
        pwd = (EditText)findViewById(R.id.pwd);

        b.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                // TODO Auto-generated method stub

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

                    nameValuePairs.add(new BasicNameValuePair("name", uname.getText().toString()));
                    nameValuePairs.add(new BasicNameValuePair("Pass", pwd.getText().toString()));

                    try 
                    {
                     HttpClient httpclient = new DefaultHttpClient();
                     HttpPost httppost = new HttpPost("http://www.helloworld.com/report.php");
                     httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                     HttpResponse response = httpclient.execute(httppost);
                     HttpEntity entity = response.getEntity();
                     InputStream is = entity.getContent();
                    }
                    catch(Exception e)
                    {
                            Log.e("log_tag","Error in http connection"+e.toString());
                    }   
            }
        });
    }
}
  • 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-06T02:25:04+00:00Added an answer on June 6, 2026 at 2:25 am
    public class Loging extends Activity{
    
        TextView txt;
        EditText uname,pwd;
        final Loging login = this; 
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.loging);
            Button loging = (Button)findViewById(R.id.log);
            Button adduser = (Button)findViewById(R.id.adduser);
            uname = (EditText)findViewById(R.id.uname);
            pwd = (EditText)findViewById(R.id.pwd);
    
    
            loging.setOnClickListener(new View.OnClickListener() {
    
    
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
    
    
                    // Create a new HttpClient and Post Header
                    HttpClient httpclient = new DefaultHttpClient();
    
                    /* login.php returns true if username and password is equal to saranga */
                    HttpPost httppost = new HttpPost("http://www.xoxoxoxox.com/login.php");
    
                    try {
                        // Add user name and password
                     EditText uname = (EditText)findViewById(R.id.uname);
                     String username = uname.getText().toString();
    
                     EditText pword = (EditText)findViewById(R.id.pwd);
                     String password = pword.getText().toString();
    
                        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                        nameValuePairs.add(new BasicNameValuePair("username", username));
                        nameValuePairs.add(new BasicNameValuePair("password", password));
                        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    
                        // Execute HTTP Post Request
                        Log.w("SENCIDE", "Execute HTTP Post Request");
                        HttpResponse response = httpclient.execute(httppost);
    
                        String str = inputStreamToString(response.getEntity().getContent()).toString();
                        Log.w("SENCIDE", str);
    
                        if(str.toString().equalsIgnoreCase("true"))
                        {
                         Log.w("SENCIDE", "TRUE");
                         //result.setText("Login successful");   
    
                         Intent in = new Intent();
                            in.setClass(login, MappingActivity.class);
                                    startActivity(in);
                        }else
                        {
                         Log.w("SENCIDE", "FALSE");
                         AlertDialog alertDialog = new AlertDialog.Builder(Loging.this).create();
                            alertDialog.setTitle("Credentials Missing");
                            alertDialog.setMessage("Please add UserName and Password");
                            alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                               public void onClick(DialogInterface dialog, int which) {
                                  // here you can add functions
                                   Intent i = new Intent();
                                    i.setClass(login, MappingActivity.class);
                                            startActivity(i);
                               }
                            });
                            alertDialog.show();            
                        }
    
                    } catch (ClientProtocolException e) {
                     e.printStackTrace();
                    } catch (IOException e) {
                     e.printStackTrace();
                    }
    
    
                }
    
                private Object inputStreamToString(InputStream is) {
                    // TODO Auto-generated method stub
                    String line = "";
                     StringBuilder total = new StringBuilder();
                     // Wrap a BufferedReader around the InputStream
                     BufferedReader rd = new BufferedReader(new InputStreamReader(is));
                     // Read response until the end
                     try {
                      while ((line = rd.readLine()) != null) { 
                        total.append(line); 
                      }
                     } catch (IOException e) {
                      e.printStackTrace();
                     }
                     // Return full string
                     return total;
                }
            });
    
            adduser.setOnClickListener(new View.OnClickListener() {
    
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Intent in = new Intent();
                    in.setClass(login, Adduser.class);
                            startActivity(in);
                }
            });
    
    
    
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing small application in PHP that will need to store small number
I am developing a small application on Google's android emulator. I am trying to
I am developing a small application that executes shell commands and displays the output
I am developing a small application that is going to serve as viewer (sort
I'm developing an application that is so far using HttpListener to provide a small
I'm developing a small C# application that scans a log file for lines containing
I'm currently developing an iPad application that integrates MapKit. But I have a small
I'm developing a small application that reads data from a database and displys it
I am developing a small web application that uses jquery's drag and drop. Problem
I am developing a small android application in that i want find the mobile

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.