Android MySQL Database Tutorial – Android Login with PHP MySQL




 


Video Instructions


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


  • George

    Hey Prabeesh
    I have used your codes to learn. Just the way it is . The program installand when I try to run ,The screen is stuck with ‘Login Status’

    • George

      Sorry got it working.

      • Maha

        please i have the same error When i click the LOgin Button the AlertDialog is empty!! there is only the title that i set in onPreExecute()..and throw IO Exception . Any ideas about my problem?

        • Maha

          it is worked .. my manifest.xml had an error ..it shoud be like that

          not like that

          • Someshvar Vashisht

            what u fixed in manifest.xml file?

      • Puck

        How did you fix it?

  • Sarwar

    nice

  • Sarwar

    Hello, I just watched your “Android MySQL Database Tutorial – Android Login with PHP MySQL” video on youtube. it’s awesome.
    bt problem is i have done like yours bt when i click on login button it shows alert box bt not successful msg

    • Prateek

      You can use the android studio virtual device then may be it will work.
      Actually i m also using genymotion but in that the same code is not working.
      but when i thought to run with android own vitual device then it is working fine so do that may be it will work for u too as it is working for me.

    • androidDev

      I have same problem ! did you find any solution?

  • Prateek

    Same problem need help

  • Someshvar Vashisht

    please i have the same error When i click the LOgin Button the AlertDialog is empty!! there is only the title that i set in onPreExecute()..and throw IO Exception . Any ideas about my problem?

  • Alex Simion

    Hello,
    Very useful code. Thank you for that! I have a problem though and I cannot manage to find the reason. As I have a hosting account I did this tutorial directly on a sql data base that I created online. My hosting is with Ipage. They have a Cpanel but is not exactly how you show it in your video. I have followed every step created everything without any error but now when I launch the app on my phone and I introduce the username and password the answer is always the Alert dialog (Login Status) and the message from login.php login not success. Where do you think could be the problem? Once I get the message from the login.php it means that the app connects to the online files but somewhere here there is a problem $result = mysqli_query($conn ,$mysql_qry);
    if(mysqli_num_rows($result) > 0)

    Please any suggestion is welcomed!

    • Fabio J. Palacios

      try this line in your login.php file:

      $mysql_qry = “select * from employee_data where user_name ='”.$user_name.”‘ and password='”.$user_pass.”‘”;

    • Sahrish Khan

      Hello i have Also the Same problem. please if you solve the problem then please reply me.

      • Alex Simion

        In my case the problem was that in the php file I had an extra space. So check it propperly as a single extra space can mess up the result of the connection.

        • Sahrish Khan

          but how can i find the extra space .can you send me snapshot on my email id sahrishkhan534@gmail.com

        • Sahrish Khan

          thanks a lot my problem is solve .this is best method

          • Alex

            Hey there,
            I have the same problem as you, but in my case, I have no idea where I can get an extra space in php file… Any other suggestions?
            Thanks in advance.

          • Sahrish Khan

            send me the pictures of php files i will highlight the spaces.

          • Alex
          • Sahrish Khan

            0){
            echo “login success “;
            }
            else {
            echo “login not success”;
            }
            ?>

          • Sahrish Khan

            your query was wrong

          • Sahrish Khan

            your database name is lekarz?

          • Alex

            yes, I’ve created slightly different database to my thesis. Thanks a milion! You saved my life – literally 🙂

          • Sahrish Khan

            you can mail me your all coding of php on my email id sahrishkhankhan@gmail.com..i try to solve

          • Spectre Video

            hey bro r u solve this myproblem?

          • Sahrish Khan

            what is is your problem ? mention it.

          • Spectre Video

            $mysql_qry = “select * from employee_data where user_name ='”.$user_name.”‘ and password='”.$user_pass.”‘”;

            $result = mysql_query($mysql_qry) ;

            if(mysql_num_rows($result) > 0) {
            echo “login success !!!!! testeeooo”;
            }
            else {
            echo “login not success”;
            }

            in these code it will give login not sucess on app application but it will run on cpanel or browser

          • Sahrish Khan

            0){
            echo “login success !!!!! testeeooo”;
            }
            else {
            echo “login not success”;
            }
            ?>

          • Sahrish Khan

            try that code because in your code you missed specific word like.

          • Spectre Video

            bro after click on login button it will show alert box with connection success……..but login unsuccessfull

          • Sahrish Khan

            0){
            echo “login success !!!!! testeeooo”;
            }
            else {
            echo “login not success”;
            }
            ?>

    • Spectre Video

      hey bro can you solve this problem? because i face same problem

  • Oscar Shaitan Tigreros

    with the same code i have a error
    javax.net.ssl.SSLHandshakeException: Handshake failed
    Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xad51f980: Failure in SSL library, usually a protocol error
    error:100bd10c:SSL routines:ssl3_get_record:WRONG_VERSION_NUMBER
    any ideas?

  • Fabio J. Palacios

    Very very good. Everything it’s fine..The only parts I had to change were in php (maybe a version issue):
    1- conn.php file

    This works fine:

    $link = mysql_connect($host, $username, $password);
    if (!$link) {
    die(‘Error al conectarse a mysql: ‘ . mysql_error());
    }

    $db_selected = mysql_select_db($database, $link);

    2- login.php file
    $mysql_qry = “select * from employee_data where user_name ='”.$user_name.”‘ and password='”.$user_pass.”‘”;

    $result = mysql_query($mysql_qry) ;

    if(mysql_num_rows($result) > 0) {
    echo “login success !!!!! testeeooo”;
    }
    else {
    echo “login not success”;
    }

  • RonanLafford

    Hi, thanks for the great tutorial,

    Hopefully this may help you all. I had the same issue with the Login dialog. Here is what worked for me. In this line below, I did not notice the semi colon between the single quotation mark and the last double quotation marks in the video. I added the semi colon and now it is giving the successful message and working fine.

    $mysql_qry = “select * from employee_data where username like ‘$user_name’ and password like ‘$user_pass’;”;

    Hope this can be of help.

  • Muhammad Nauman
  • SAMEER RAJPAL

    Hi! 1st of all thanks a lot for your, all very very useful tutorials… i just got a problem here is… whenever i am clicking on login button it’s just showing “Login Status” title but not showing any message like login success or not success.

    • Moch Rosin

      I face same problem, please help us

    • ravita

      when i login than i get this error
      “0) { echo “login success !!!!! Welcome user”; } else { echo “login not success”; } ?>”

      • akhila

        did you find the solution ma’am?
        please help..!!

    • akhila

      did you find the solution sir?
      please share the solution..!!

      • SAMEER RAJPAL

        Yes there was just a syntax error in my script… the script is correct, you just need to check it properly… maybe there’s a syntax error.

        • Hamza Yousaf

          i’m facing the same problem. Could you please help me

  • أنا أحب يسوع

    How to add progressbar and get flag(from php) success and fail login to Process on android, thanks

    • Vineeta Karki

      For progressbar follow following 3 steps.
      —>//Declare object of ProgressDialog in BackgroundWorker.Do not forget to import android.app.ProgressDialog class.

      ProgressDialog pd1 ;
      —>//Add this code in onPreExecute method.

      pd1 = new ProgressDialog(context);
      pd1.setTitle(“Retrieving data”);
      pd1.setMessage(“Please wait.”);
      pd1.setCancelable(true);
      pd1.setIndeterminate(true);
      pd1.show();
      —> //Add this code in onPostExecute method.

      if(pd1!=null) pd1.dismiss();

      • Gunesh Shanbhag

        when login button is clicked alertDialog says LOGIN STATUS…
        when register button is pressed from register activity alertDialog again says LOGIN STATUS…..how to change it to display as “REGISTER STATUS”…?

  • Dharma Teja Taneti

    Hello, Can you please tell me how to open new activity if login is successed! I tried startActivity method it is giving error that can n’t resolve the constructor Intent in current class is less than new activity. Please help me.

    • IndiGeeks

      Use
      Context instead of this nd

      Context.startActivity(in);

      • Nayab Qureshi

        i have same problem

    • Nayab Qureshi

      can anyone please help?

  • Jesus David

    Thanks 😀

  • Emma Nexus

    hi how can i retrieve data from database and display it on the table

    • Sicnarf Omsare

      Use jsonparser

      • Lokesh Puppala

        will you please give me a code for retrieve data and display it

  • Mujtaba Mahmood

    when i run the application on the AVD, it asks for the username and password , but when i click on the login, the application closes down. any idea?

    i am using online database not a local

  • akhila

    what are the dependencies you have added sir? im not able to get OnPreExecute method. pls resopnd ASAP

  • yumna asim

    When I click login button, it shows login status only, why?

    • khalilok

      Same problem 🙁

  • Nayab Qureshi

    how to open new activity when login succeed??