Android PHP Mysql login tutorial using HttpURLConnection

MySql

Table ‘tbl_login’ contains username and password of user.

Table holds data row like this.

PHP

  1. include config.inc.php file to connect database.
  2. Check if POST data is set from android.
  3. Query the database to see row exist or not.
  4. Return the result.

login.inc.php

config.inc.php

Android

The image on the top of page shows both MainActivity.java and SuccessActivity.java respectively.

MainActivity.java

  1. On LogIn button click checkLogin() function is triggered. Which innitiate AsyncLogin class to carry out Asynchronous task.
  2. onPreExecute(), invoked on the UI thread before the task is executed. Here We are displaying loading message.
  3. doInBackground(Params…), invoked on the background thread immediately after
    onPreExecute() finishes executing. The sending and recieving data from and to php file using HttpURLConnection class has done in this function.
  4. onPostExecute(Result), invoked on the UI thread after the background computation finishes. Here we are checking for recieved result.
  5. The parameters params[0] and params[1] is from AsyncLogin’s execute method.

activity_main.xml

The xml file for MainActivity.java.

SuccessActivity.java

This Activity is launched from onPreExecute() method after login success.

activity_success.xml

The xml file for SuccessActivity.java.

AndroidManifest.xml

Don’t forget to add uses-permission and SuccessActivity to your AndroidManifest.xml file.

https://github.com/androidcss/login-system-with-android-php-and-mysql-using-httpurlconnection

Android PHP Mysql login tutorial using HttpURLConnection

5 سال پیش

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

این سایت از اکیسمت برای کاهش هرزنامه استفاده می کند. بیاموزید که چگونه اطلاعات دیدگاه های شما پردازش می‌شوند.