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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:33:32+00:00 2026-05-16T21:33:32+00:00

I having an issue from my HTTP Post. The code I’m using are working

  • 0

I having an issue from my HTTP Post.

The code I’m using are working (have tested to post data to a guestbook form and it worked).

Now what I want. I have created two EditText forms, that holds values. I have a submit button there I post this data (like the test I wrote about before), but now I want to post it into a login.php page (that in a normal browser redirects me to the member.php page).

Although I know the forms are correctly filled in and it successfully posted on the “test” site, I wanna get the response from login.php and check if the user is successfully logged in or if it failed, if succeeded -> redirect me to member.php page.

All I know is this:

HttpResponse response = httpclient.execute(httppost); 

that executes the command. But how should I achieve the login check? Any further use of the response variable?

  • 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-05-16T21:33:32+00:00Added an answer on May 16, 2026 at 9:33 pm

    Well… your approach is not good at all. If you are going to allow user authenticate through your app, why do you want to redirect the user to a member.php page? why don’t you just put the login form in a login.php file on the server and make the user browse through your site?

    As user, if an app allows me to authenticate using EditTexts inside UI, I would expect to access all the content through the app instead of being redirected to a web interface.

    Anyway, if you decide to continue doing it that way keep in mind that you would have to parse and process cookies manually, and inject them into the WebView (Google about the CookieManager class). That’s the way how the user will really be logged-in in your web app.

    Can you provide a small example of how to set it up? The stream I will get, is that a special server response for example, a successfully login?

    Here you have:

    public String getPostRequest(String url, String user, String pass) {
        HttpClient postClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        HttpResponse response;
    
        try {
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("user", user));
            nameValuePairs.add(new BasicNameValuePair("pass", pass));
            httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    
            response = postClient.execute(httpPost);
    
            if(response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
    
                if (entity != null) {
                    InputStream instream = entity.getContent();  
                    String result = convertStreamToString(instream);
                    instream.close();
                    return result; // here is a string of the result!!!
                }
            }
        } catch (Exception e) {}
    
        return null; // if it gets here, something wrong happens with the connection
    }
    
    private String convertStreamToString(InputStream is) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();
    
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        return sb.toString();
    }
    

    How do you use it? Something like this:

    String result = getPostRequest("http://yourpage.com/login.php", "the username", "his/her pass");
    if( result.equals("OK") ){
        // voila!
    }
    

    I’m here supposing that you have something like this in your PHP code:

    <?php
    // login logic here
    
    if( $success ){
        die("OK");
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble understanding how to issue an HTTP POST request using curl from
http://jsfiddle.net/fSrBv/ I'm having an issue here where in my From field I'm able to
I'm having an issue coming in from Crashlytics. I have debugging parameters on so
Hi guys I am having issue I have this query: SELECT * FROM useraccount
i'm having an issue PInvoking a native function from c++... i have PInvoked all
I am having an issue removing %3Cbr+%2F%3E from my string using the preg_replace function.
I am having an issue handling HTTP URL Connections that do not return data.
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I'm having an issue sending a huge (~4MB) block of data from flash, to
I am having an issue trying to post a JSON string using dojo.xhrPost to

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.