title: Android Studio Login Page with php connect to localhost how start other activitie java if username and password is correct
body: <p>I create new project in Android Studio. Did login Page. Did php file to check if username and password is Correct.</p>
  
  <pre><code>&lt;?php
  require "conn.php";
  $user_name = $_POST["user_name"];
  $user_pass = $_POST["password"];
  $mysql_qry = "select * from employee_data where username like '$user_name'and password like '$user_pass'";
  $result = mysqli_query($conn ,$mysql_qry);
  if(mysqli_num_rows($result) &gt; 0) {
  
  echo"login success";
  
  }else {
  
  echo "login not success";
  }
  ?&gt;
  </code></pre>
  
  <p>My java Code in Android Studio</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  EditText etnomedeutilizador, etpassword;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      etnomedeutilizador = (EditText)findViewById(R.id.etnomedeutilizador);
      etpassword = (EditText)findViewById(R.id.etpassword);
  }
  public void botaologinonClick(View view) {
      String username = etnomedeutilizador.getText().toString();
      String password = etpassword.getText().toString();
      String type = "login";
      BackGroundWorker backGroundWorker = new BackGroundWorker(this);
      backGroundWorker.execute(type, username, password);
      System.err.println("aspas");
  </code></pre>
  
  <p>My java (BackGroundWorker) code is this</p>
  
  <pre><code>public class BackGroundWorker extends AsyncTask&lt;String,Void,String&gt; {
  Context context;
  AlertDialog alertDialog;
  BackGroundWorker (Context ctx) {
      context = ctx;
  }
  @Override
  protected String doInBackground(String... params) {
      String type = params[0];
      String login_url = "http://192.168.1.79/login.php";
            if(type.equals("login")) {
          try {
              String user_name = params[1];
              String password = params[2];
              URL url = new URL(login_url);
              HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
              httpURLConnection.setRequestMethod("POST");
              httpURLConnection.setDoOutput(true);
              httpURLConnection.setDoInput(true);
              OutputStream outputStream = httpURLConnection.getOutputStream();
              BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
              String post_data = URLEncoder.encode("user_name", "UTF-8") + "=" + URLEncoder.encode(user_name, "UTF-8") + "&amp;" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8");
              String user = URLEncoder.encode(user_name, "UTF-8");//guarda o nome de utilizador introduzido
              String pass = URLEncoder.encode(password, "UTF-8");//guarda a pass introduzido
              System.err.println("------------------------------------------");
               /*/  if(user.equals("Nome de Utilizador")){
                     if(pass.equals("Password")) {
                         System.err.println("Entrou no if");
                         startActivity(new Intent(this, Pagina1.class));}
               /*/
  
  
  
  
              bufferedWriter.write(post_data);
              bufferedWriter.flush();
              bufferedWriter.close();
              outputStream.close();
              InputStream inputStream = httpURLConnection.getInputStream();
  
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
              String result="";
              String line="";
              while((line = bufferedReader.readLine())!= null) {
                  result +=line;
  
              }
  
              bufferedReader.close();
              inputStream.close();
              httpURLConnection.disconnect();
              return result;
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>Question: If my username and password are correct with my DataBase(localhost) i want to start new activitie in my Android Studio after message shown from php (Login Success).
  <a href="http://i.stack.imgur.com/TVfpz.png" rel="nofollow">Login Success</a>
   if username and/or password wrong
   show message from php (login not success).
  <a href="http://i.stack.imgur.com/x81HS.png" rel="nofollow">Wrong Password</a></p>
  
  <p>To me more specified, application stays in "Login Success" message from php and i want it to start new activitie java in my Android after that.</p>