Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So first the Android stuff: You're getting this <code>NetworkOnMainThreadException</code> because you're trying to make a HTTP request on your main application thread which is the UI thread. You shouldn't do any blocking operations in this thread. Use an <a href="https://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">AsyncTask</a> instead.</p> <p>I'm not quite sure what's causing the <code>IllegalArgumentException</code> but I guess it's this line:</p> <pre><code>response = CustomHttpClient.executeHttpPost("http://127.0.0.1/es/check.php", postParameters); </code></pre> <p>You have probably changed the URL (localhost usually doesn't make sense on a phone). The scheme part is the <code>http</code>. Maybe you have something like <code>" http://..."</code> (note the leading space character) in the original code?</p> <p>Short note on the PHP:</p> <pre><code>$sql = 'SELECT * from people WHERE username = "' .$_POST['un'] . '" and password = "' .md5($_POST['pw']) . '"'; </code></pre> <p>That's what you call an <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow">SQL injection</a>.</p> <p><strong>Update:</strong> Here's some example. Didn't test it, hopefully it works.</p> <pre><code>public class LoginLayout extends Activity { EditText un,pw; TextView error; Button ok; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); un=(EditText)findViewById(R.id.et_un); pw=(EditText)findViewById(R.id.et_pw); ok=(Button)findViewById(R.id.btn_login); error=(TextView)findViewById(R.id.tv_error); ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new LoginTask().execute(un.getText().toString(), pw.getText().toString()); } }); } private class LoginTask extends AsyncTask&lt;String, Void, Object&gt; { protected Object doInBackground(String... params) { ArrayList&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;(); postParameters.add(new BasicNameValuePair("username", params[0])); postParameters.add(new BasicNameValuePair("password", params[1])); String response = null; try { response = CustomHttpClient.executeHttpPost("http://127.0.0.1/es/check.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+",""); return res; } catch (Exception e) { return e; } } protected void onPostExecute(Object result) { if (result instanceof String) { if (result.equals("1")) { error.setText("Correct Username or Password"); } else { error.setText("Sorry!! Wrong Username or Password Entered"); } } else if (result instanceof Exception) { un.setText(result.toString()); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload