Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void loginPost(View view){
- String username = usernameField.getText().toString();
- String password = passwordField.getText().toString();
- try{
- String link="http://mwssong.esy.es/android/Login.php";
- String data = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8");
- data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8");
- URL url = new URL(link);
- URLConnection conn = url.openConnection();
- conn.setDoOutput(true);
- OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- wr.write( data );
- wr.flush();
- BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- StringBuilder sb = new StringBuilder();
- String line = null;
- // Read Server Response
- while((line = reader.readLine()) != null)
- {
- sb.append(line);
- break;
- }
- if(sb.toString()=="admin")
- new AdminScreen();
- else if(sb.toString()=="Customer")
- {
- Intent myIntent(view.getContext(),AdminScreen.class);
- startActivity(myIntent);
- }
- else
- status.setText(sb);
- }
- catch(Exception e){
- status.setText("Exception: " + e.getMessage());
- }
- Intent myIntent(view.getContext(),AdminScreen.class);
- startActivity(myIntent);
Add Comment
Please, Sign In to add comment