-1

i'am tring to login into website with post method ... to right here the code is code but the response always give me 200 ... i want to know if i logged in successfully with the right username and password or not !!! ... also if i removed permitAll() it give me networkonmainthreadexception

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressLint("NewApi")
private void sendPost()  {

     // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("https://svuonline.org/isis/login.php?");

    String user=username.getText().toString();
    String pass=password.getText().toString();
    String fpage="/isis/index.php";

  /*  if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }*/

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("user_name", user));
        nameValuePairs.add(new BasicNameValuePair("user_pass", pass));
        nameValuePairs.add(new BasicNameValuePair("user_otp", null));
        nameValuePairs.add(new BasicNameValuePair("from_page", fpage));

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

        String Rcode=response.toString();

        Toast.makeText(getBaseContext(), Rcode+"", Toast.LENGTH_LONG).show();

    } catch (ClientProtocolException e) {
        Toast.makeText(getBaseContext(), e+"", Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        Toast.makeText(getBaseContext(), e+"", Toast.LENGTH_LONG).show();
    }
}
Omar
  • 37
  • 1
  • 10
  • Why don't you try to print the response instead of the statusCode() – kabuto178 Mar 31 '14 at 21:09
  • 1
    for one, don't leave empty catch blocks like that. secondly, your url appears to be `login.php`, not `index.php`, according to the source of the page. finally, don't ever ever use `permitAll`. – njzk2 Mar 31 '14 at 21:21
  • ok guys i used your hints ... please check the edited Question text agine ...i'am new with android by the way !! – Omar Apr 01 '14 at 19:40

1 Answers1

0

You can read about it here:

HTTP response

10.2.1 200 OK

The request has succeeded. 
ruhungry
  • 4,506
  • 20
  • 54
  • 98