as the tittle indicates just want to get data from my php file & check whether entered email , password are of a registered user . If yes then redirect to Success page(TimelineActivity)
Hence had look on this :- How to get values from mysql database using php script in android
This my LoginBasicActivity.java
public class LoginBasicActivity extends AppCompatActivity {
public AutoCompleteTextView uemail;
public EditText upassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_basic);
uemail = (AutoCompleteTextView) findViewById(R.id.emailBasic);
upassword = (EditText) findViewById(R.id.passwordBasic) ;
Button buttonLog = (Button) findViewById(R.id.buttonLog);
buttonLog.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String tem;
String email = uemail.getText().toString();
String result = null;
String password = upassword.getText().toString() ;
// HttpClientBuilder.create();
// As HttpClient client = new DefaultHttpClient(); is not used anymore
HttpClient client = HttpClients.createDefault();
tem = "http://www.example_domain.com/app_folder/verify-user.php?username="+email+"&password="+password;
HttpGet request = new HttpGet(tem);
try {
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr);
result = reader.readLine();
} catch (Exception e) {
e.printStackTrace();
}
if (result.equals("0") == true) {
Toast.makeText(getApplicationContext(), "Sorry try again", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Welcome Client", Toast.LENGTH_LONG).show();
Intent myIntt = new Intent(view.getContext(), TimelineActivity.class);
startActivityForResult(myIntt, 0);
}
}
});
}
}
This is verify-user.php
<?php
mysql_connect("localhost","user_name","user_password") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
$SelectQuery="select * from table_name where C_Username='$username' and C_Password='$password'";
$result=mysql_query($SelectQuery) or die(mysql_error());
$count=mysql_num_rows($result);
$row=mysql_fetch_array($result);
if($count==0)
echo "0";
else
echo $row['c_id'];
?>
After this i got some file duplication issue in build.gradle , so added this in build.gradle
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
}
}`
Now , when Login button is pressed dialogbox says "Unfourtunately app_name has stopped "
Logcat :- https://www.dropbox.com/s/63cv806z4y8h9my/2015-11-10-05-01-44%5B1%5D.txt?dl=0
Im little bit new to Android-Java.
How to fix this issue ? Can someone explain correct syntax , where its going wrong ?