The likely reason many people are having issues with this code is that the AsyncTask was deprecated from API 30. There is a new method that I am looking into at the time of writing this post. When I ran an emulator with Lollipop (API 22) it worked. I don't have a solution for the latest API version, but perhaps the author could post an updated video. Thanks #ProgrammingKnowledge, this was an amazing video despite the version change.
For those who stuck, try check if the button created has a onclick action linked to the onlogin method, it was shown in the code shared but never shown in the video
my dear folks. He proofed that his code is working perfectly. I also did it, and it works, on my webserver. When you forget to do only a semicolon, a doubleacent or just one letter, it messes up the whole code. example for me, I forgot the "&" in the android url. I always got "login not sucess". Thanks for the tutorial!!
What do you mean by the "android url"? I am also always getting a login failure unless I hard code the username and password in the php file instead of using $_POST.
For those doing this in 2019 and having blank" login status" problem. make you String login_url = "10.0.2.2:80/login.php"; where the :80 is your port number. Mine for xampp and wamp by default was 80. Also you need to include clear text. In your manifest file, add this android:usesCleartextTraffic="true" in the application tag. make sure you use this and not android:allowClearUserData as this is the first thing that you can tab complete if you type clear. hope this helps
to every people who have a blank space in their AlertDialog when they use a device, but it works fine and write "Login successfull" when they use an emulator, it's normal!! Don't panic, the tutorial works perfectly. It's just that the device works on wifi, and then doesn't have access to the database because it doesn't have access to the PC localhost..
For everyone who has the problem on just the title of the alert dialog appears, put this android:usesCleartextTraffic="true" in yout Manifest application tag. Like this:
...
Or see this guy link: stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
Guys i solved my problem with login message not showing, my mistake was kind of stupid lol towards the end i lost focus and closed the video and when i came back i skipped the few seconds at the end which involve the onPostExecute. Make sure ypu modify that at the end just before he allows android to connect to INTERNET. this said thamks man for the tutorials.
You saved me, I was trying all day connect my phone to PHP, ohhh that was pretty hard. Thanks you, you made my day. (when i said day, i meant day and half of night. It's 3AM here)
I have a question. I tried using this method but I'm not able to get the value of the result string from the doInBackground method into MainActivity. how do I do that? I essentially want to take the string value for 'result' that was received in BackgroundWorker and save it to a variable in MainActivity
thank you so much for this tutorial.i have a problem. everything is in code is ok but when I run my app it crashes .what should I do and also I am using xamp server instead of wamp server some plz help me..
best android programming tutorial ever! :) one question though. please make also select query from mysql database and display it on listview. thank you so much.
Shashwat Singh 1 second ago For newer versions of android studio, people getting blank alertDialog. Add this line in your "AndroidManifest.xml" Inside
. . . android:usesCleartextTraffic="true" . This is because newer versions require the user to give permission to the app to allow exchange of text over HTTP
Hello Sir, First of all thank you very much for this important tutorial.. But I want to ask you one thing that what if I login from my android device? I mean what should I give the IP address for that?
Help me bro again, @Override protected void onPostExecute(String result){ alertDialog.setMessage(result); alertDialog.show(); } On real device String result gives null, what the reason, please help bro
It doesnt work on real device because you cant connect to your database through your device.The app on your android phone cant fint the login.php file which is on computer.You can only fint it using virtual device!
@@herrypapaiya694 by default phpmyadmin has restrictions on your database making it accessible only through local host. Thats why the virtual device can access the db because it's running on the host pc. You can simply allow other devices on the same network to acceess by editing the phpmyadmin.conf. You can find the exact details by searching "Allowing remote access to phpmyadmin" on google.
Hello friend. After logging I am getting message"Login status". And ip address as you showed. When I run ipconfig - I don't get wireless lan adapter, only Ethernet adapters. Am I missing something? Or my pc is not working properly? Thank you
those who were able to run the code perfectly fine in AS emulator but only getting the log in status alert dialog in their phone, you need to check in your phone browser if you can access the IP address that was set and being accessed in your AS emulator. If not, you need to add a new rule in your firewall. >go to windows firewall. >inbound rules >new rule >select port>next >all programs>next >specify the port that your AS emulator was accessing or the port where your wamp is listening(in my case im using port 8080) >hit next then >allow connection>next >leave everything as ease(domain,private and public are checked by default) >your preferred name, mine was WAMP,. and your done. Go back in your phone browser, and refresh the page earlier. and BTW, do not forget to put your wamp server online.
I know its old but since some people still have problems should also add: You need to setup port forwarding in your router for your port( typically port 80 or 8080) if you set it up for only your local internet your phone has to be connected to your wifi to be able to access it. to check, try accessing the login webpage from another computer in the house. if you port forward it globally ( so any computer anywhere can access the webpage) then you should be able to use it without wifi but make sure to make the ip address in the code is your public ip address, you can check that at "whatsmyip.org"
Jacob Hughes how can I do this port forwarding. I'm using xampp server and I put the ip address of computer which appears when I type ipconfig in command prompt.My computer is connected to my phone's net.But still my app stop's working when I click login button. Any help is appreciated.
Hello Sir, thanks for the useful tutorial but I have a problem..... When i click the LOgin Button the AlertDialog is empty!! there is only the title that i set in onPreExecute()... Any ideas about my problem?
Hello my friends i had to that problem before i figured out that like that; Go to C:\wamp64\bin\apache\apache2.4.18\conf\extra and edit httpd-vhosts file and change it require all granted
Thanks 4 your help, but I need validate as it is, and move to another activity if it is valid, instead of login success! how can I do it? please help me
For those who want to know. Here's how you do it: first you add a global context variable inside the public class like this "Context context_var_name;" then in the "onPostExecute" method you write this code: if(result.equals("login success")) { Intent I = new Intent(context,my_class_name.class); context.startActivity(I); } Let me know if this helps!! or you any issues!!
@@shoebnayeem4104 For those who want to know. Here's how you do it: first you add a global context variable inside the public class like this "Context context_var_name;" then in the "onPostExecute" method you write this code: if(result.equals("login success")) { Intent I = new Intent(context,my_class_name.class); context.startActivity(I); } Let me know if this helps!! or you any issues!!
Good video, but needs more explanation of what's going on. This is more like copy and pasting what you are doing. What does aVoid for input parameter do?
Thanq for this great video very helpfull... its working fine i just make changes in it that when user-&-password will correct it will open a new activity bt.. their im getting trouble in fetching data on the new activity ! how to show the data i.e., name of the user on new activity ?
Thanku for the video tutorials. Sir can you create a tutorial or continuation wherein after successful login you will be redirect to another class which for example user profile.
Late reply! But might be useful for others! When you click on the login button you have to use an "intent", to take you to user profile activity. This video- th-cam.com/video/bgIUdb-7Rqo/w-d-xo.html can help you.
Hi, I am using Android studio 3.1.3 version. I texted entire code as you explained. When I am running the app in api 24, its working fine. But when I am trying to run in marshmallow or kitkat or any other version its not working after clicking on button(Stopped & closing app). Plz tell me if any libraries to add in the dependencies. Thank you.
Hi guys! For all those using their phones and to run the app and always gets a "Login Status" but no result message, I kinda have figured it out, for my case though. I ran through the app reading it line by line and found out my error was in a.) conn.php file, my table name was wrong and b.) if(type.equals("login") was written as if(type.equals("Login"), which is wrong. I changed the L to small l and along with the php script correction, it worked.
+Rafiatou BIRAMAH remove alertdialog.show(); and put condition like this // alertDialog.show(); if (result.contentEquals("done")) { Intent intent = new Intent(getApplicationContext(), Home.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //intent.putExtra("key", email); getApplicationContext().startActivity(intent); } else { Toast.makeText(getApplicationContext(), "Email or password is wrong", Toast.LENGTH_SHORT).show(); } enjoy :)
very great tutorial though I have a question... I have created several cases in the switch statement and they work just fine but how do I add ProgressDialogs for specific cases?? thanks
For login_url if you have a web host would you just use the http of the web host to connect? For example my login.php is located at digdug.cs.emerson.edu/ext/login.php Would I set login_url equal to that to get the right input or no?
The likely reason many people are having issues with this code is that the AsyncTask was deprecated from API 30. There is a new method that I am looking into at the time of writing this post.
When I ran an emulator with Lollipop (API 22) it worked.
I don't have a solution for the latest API version, but perhaps the author could post an updated video.
Thanks #ProgrammingKnowledge, this was an amazing video despite the version change.
For those who stuck, try check if the button created has a onclick action linked to the onlogin method, it was shown in the code shared but never shown in the video
Solved it! I changed my emulators API level and it worked
your voice is so kind and u are explaining realy good, keep going man !!!
my dear folks. He proofed that his code is working perfectly.
I also did it, and it works, on my webserver.
When you forget to do only a semicolon, a doubleacent or just one letter, it messes up the whole code. example for me, I forgot the "&" in the android url. I always got "login not sucess".
Thanks for the tutorial!!
my crash after replicate everything
What do you mean by the "android url"? I am also always getting a login failure unless I hard code the username and password in the php file instead of using $_POST.
At the very end if the url line in your java code, I forgotten the & its barely visible in the video above. Check again yout java code dude!:)
+Emanuel Graf Do you mean the & at the end of the first line of the post_data string? Thanks
Yes man in my case was it this '&'. But in your case maybe another char? Let me know!
For those doing this in 2019 and having blank" login status" problem. make you String login_url = "10.0.2.2:80/login.php"; where the :80 is your port number. Mine for xampp and wamp by default was 80.
Also you need to include clear text. In your manifest file, add this
android:usesCleartextTraffic="true"
in the application tag. make sure you use this and not android:allowClearUserData as this is the first thing that you can tab complete if you type clear.
hope this helps
i love when you people do this
thank your so muuuch !!!!!!!!!
to every people who have a blank space in their AlertDialog when they use a device, but it works fine and write "Login successfull" when they use an emulator, it's normal!! Don't panic, the tutorial works perfectly. It's just that the device works on wifi, and then doesn't have access to the database because it doesn't have access to the PC localhost..
Michel Monnier , so sir what can we do to solve it?
this code is working well thank you so much! (if u guys have a problem, try to use ur PC and ur Phone in the same internet wifi connection) :)
very great tutorial ... you are the best on all the world in connect the android app with mysql
....Thank you
This is by far the best tutorial avaliable on android database connection
Great sir. It helps alot. I love your way of teaching..... who is agree?
For everyone who has the problem on just the title of the alert dialog appears, put this android:usesCleartextTraffic="true" in yout Manifest application tag. Like this:
...
Or see this guy link:
stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted
ohh was looking for an answer for half a day, you saved me!
thanks dude..... its worked for me....🤗
thank youuuuuuu
Guys i solved my problem with login message not showing, my mistake was kind of stupid lol towards the end i lost focus and closed the video and when i came back i skipped the few seconds at the end which involve the onPostExecute. Make sure ypu modify that at the end just before he allows android to connect to INTERNET. this said thamks man for the tutorials.
That is a lot of programming but it works thanks :-)
For those who are just getting a login status dialogbox just turn off your firewall.
You saved me, I was trying all day connect my phone to PHP, ohhh that was pretty hard. Thanks you, you made my day. (when i said day, i meant day and half of night. It's 3AM here)
Code is working if someone find any difficulty they should check exception in verbose regaring FILEIOException or connection problem
Mr. ProgrammingKnowledge! You are amazing! I rather used my real android device, and your code still works perfectly!
How do you run it on your real device? Are you using different ip?
I tried run my app on my real device but it only showed blank alert dialog.
Find More Codes On My Website - www.codebind.com/
thanq soo much this code helped me a lot
I spent a year trying to figure out how to connect to a database till this video helped me. so thank you so much
Sir thanku very much. God bless u for teaching us.
Dear Jayadev,
how can I login successfully with an actual Android device? Thank you!
Hung from Vietnam
VIRGO UCHIHA same problem for me..??
Excellent...I just tried in my Android mobile for my real website.
THANKYOU VERY MUCHH. FINALLY I CAN RUN MY PROGRAM 😁
I have a question. I tried using this method but I'm not able to get the value of the result string from the doInBackground method into MainActivity. how do I do that? I essentially want to take the string value for 'result' that was received in BackgroundWorker and save it to a variable in MainActivity
Best Teacher Ever! Thank you
Excellent tutorial ! thank you.
For those who got empty AlertDialog ,
try to add android:usesCleartextTraffic="true" in Manifest.xml,
then uninstall the app and run it again.
Thanks alot
u are a real Champion dude :D your name is truth
What do you mean by uninstalling? And where exactly do I add this line in the Manifest?
@@Scott-zi7xv uninstall it from your phone
@@MuslimMan7 Its on emulator, tho
I'm so thankful for this tutorial.
Thank you. I followed your instructions and it works!
Thanks for the amazing tutorial. it worked for me.
Thank You SO Much Sir...
Please share any video to display complete data from table and images as well
thank you so much for this tutorial.i have a problem. everything is in code is ok but when I run my app it crashes .what should I do and also I am using xamp server instead of wamp server some plz help me..
did u fix the problem i have the same problem
you are breathtaking
Very useful tutorial.... really appreciated
best android programming tutorial ever! :) one question though. please make also select query from mysql database and display it on listview. thank you so much.
Really Great Tutrorial
too Simple to learn
Thank you for posting Sir
Please comment your code here as a reply( both java and XML code files please)
Wow it is really great lecture!!
Thanks alot!
when i am using emulator,everythings working fine.
but when i use device result is returning null
what to do?
Did you get the answer?
you are BEST! THANK YOU SO MUCH, Udemy not help me like you, thank you a lot!
Awesome tutorial for beginners.
Thank you so much. You helped me understand this a little better.
Good job, thank's
Works perfectly. I receive the entire table data in a single variable - result. How do I display it in a tableview or something?
Im running it on my mobile but it shows only login status title y this is not showing about connection success or not?
Shashwat Singh
1 second ago
For newer versions of android studio, people getting blank alertDialog. Add this line in your "AndroidManifest.xml"
Inside
.
.
.
android:usesCleartextTraffic="true"
.
This is because newer versions require the user to give permission to the app to allow exchange of text over HTTP
@@shashwatsingh1595 Thank you so much brother. This was frustrating me for 2 days, and it finally worker because of your advice.
I m still getting the same problem plz help
is it fine to use Xampp? and put the database connection and the login in htdocs?
GREAT TUTORIAL. THANK YOU.
Great tutorial as always!
Fantastic tutorial!!
Just you change post method because write in small latter
You changed "POST"
code working fine
Your Videos Are The Best! Made my life so much easier! Thank you!
muito boa sua aula! very good!
Great video. I'll try it tomorrow.
Thanks alote for this free courses.
Hello Sir,
First of all thank you very much for this important tutorial.. But I want to ask you one thing that what if I login from my android device? I mean what should I give the IP address for that?
have u got the solution for this?
Hello, newbie here, what do u mean by try at online website:/
use localhost or your ipv4 address of pc.
Thank you.. my problem has been solved.. :)
Nice tutorial..
snd me your code in the format of .txt
my mail is armananso729@gmail.com
Good tutorial sr, i have tried and works pretty good. Thanks!
Help me bro again,
@Override
protected void onPostExecute(String result){
alertDialog.setMessage(result);
alertDialog.show();
}
On real device String result gives null, what the reason, please help bro
It doesnt work on real device because you cant connect to your database through your device.The app on your android phone cant fint the login.php file which is on computer.You can only fint it using virtual device!
@@amarprasovic4200 so what is the solution for using the app on real devise?
@@ruthdamayantipatriciasimam8153 Allow the device to connect to phpmyadmin on the computer by granting permissions in wamp. By default its host only.
@@pravanageesara2567 didn't understand, please explain step by step!
@@herrypapaiya694 by default phpmyadmin has restrictions on your database making it accessible only through local host. Thats why the virtual device can access the db because it's running on the host pc. You can simply allow other devices on the same network to acceess by editing the phpmyadmin.conf. You can find the exact details by searching "Allowing remote access to phpmyadmin" on google.
Thank you for your video it solve my problem
Really nice tutorial, got it to work.
Hey brother, I follow this tutorial and it's very nice. Thank you!
Hello friend. After logging I am getting message"Login status". And ip address as you showed. When I run ipconfig - I don't get wireless lan adapter, only Ethernet adapters. Am I missing something? Or my pc is not working properly? Thank you
Thanks sir, awesome tutorial video !
those who were able to run the code perfectly fine in AS emulator but only getting the log in status alert dialog in their phone, you need to check in your phone browser if you can access the IP address that was set and being accessed in your AS emulator. If not, you need to add a new rule in your firewall.
>go to windows firewall.
>inbound rules
>new rule
>select port>next
>all programs>next
>specify the port that your AS emulator was accessing or the port where your wamp is listening(in my case im using port 8080)
>hit next then
>allow connection>next
>leave everything as ease(domain,private and public are checked by default)
>your preferred name, mine was WAMP,. and your done.
Go back in your phone browser, and refresh the page earlier.
and BTW, do not forget to put your wamp server online.
still cannot, how?
I suspected a problem with firewall but it still doesn't work. :/
I know its old but since some people still have problems should also add: You need to setup port forwarding in your router for your port( typically port 80 or 8080) if you set it up for only your local internet your phone has to be connected to your wifi to be able to access it. to check, try accessing the login webpage from another computer in the house. if you port forward it globally ( so any computer anywhere can access the webpage) then you should be able to use it without wifi but make sure to make the ip address in the code is your public ip address, you can check that at "whatsmyip.org"
Jacob Hughes Still it has the same problem.. please help anyone
Jacob Hughes how can I do this port forwarding.
I'm using xampp server and I put the ip address of computer which appears when I type ipconfig in command prompt.My computer is connected to my phone's net.But still my app stop's working when I click login button.
Any help is appreciated.
i copied your code pin to pin but still im not getting alert dialog box,, sooo what to do now
great work bro
tnx its really nice tutorial.helps me lot.
Hello sir, Thank you working perfectly also an my phone
i have to thank you for your great job you did for all us, i have to say i paid about 5.500 $ for a course and you teach better then they
me too .. if you solve it plz tell me howme too .. if you solve it plz tell me how
i solved it by $user_name = $_POST["user_name"];
it was $_post in small letter
you have to mach it with httpURLConnection.setRequestMethod("POST");
Very good! thanks.
thanks for sharing, good luck always
Why did you choose to make UsernameEt and PasswordEt capitalized? Shouldn't those start with lowercase?
Hi,
This works great, but I was wondering how you'd move to a new Activity page when successfully logged in? Many thanks so far.
use intent
Where can I do it? I cant get it
Put this in the onPostExecute method:
context.startActivity(new Intent(context, PutYourDestinationClassHere.class));
how to make redirect only if username and password are correct (thank u for that answer u gave - very useful)
already fund soultion:
@Override
protected void onPostExecute(String result) {
alertDialog.setMessage(result);
if(result.contentEquals("login success(or whatever u have in your php file)")) {
context.startActivity(new Intent(context, AfterLogin.class));
}else
{
Toast.makeText(context, "Wrong Username or Password!", Toast.LENGTH_SHORT).show();
}
}
Hello Sir, thanks for the useful tutorial but I have a problem..... When i click the LOgin Button the AlertDialog is empty!! there is only the title that i set in onPreExecute()... Any ideas about my problem?
me too i have this problem
Hello my friends i had to that problem before i figured out that like that;
Go to C:\wamp64\bin\apache\apache2.4.18\conf\extra and edit httpd-vhosts file and change it require all granted
still having the same problem!!
i have the same problem 😢
i too have the same problem,did anyone got the solution????????
Thanks man. Great help.
Me ayudo mucho te felicito gracias ! :D
substituting 10.0.2.2 with my pc ip address solved my problem
thank you so much sir
god bless you
Bimal Grg
Means
10.0.2.2.192......
This type of ip u mention
You are the best :D Thanks for sharing this good tutorial! You are very clear!
Thanks a lot..
Thanks buddy ! Finally I got it.
Hey.. nice video there ! Just wanted to ask.. for connecting to a website that I have in a webhost.. The url is enough or the I.P address ?
Thanks You Very helpful
Ótimo estou aprendendo muito nesse canal.
Thanks for the solution!! I've been looking for this!! :D
finished, thank you
Thank you !!! i had to make some modifications but it worked
im getting only login status and it isn't showing the result. please help.
Thanks for the awesome tutorial!
Thanks 4 your help, but I need validate as it is, and move to another activity if it is valid, instead of login success! how can I do it? please help me
Plz apko ans mil gaya ho to mujhe bhi batao plz
For those who want to know. Here's how you do it: first you add a global context variable inside the public class like this
"Context context_var_name;"
then in the "onPostExecute" method you write this code:
if(result.equals("login success")) {
Intent I = new Intent(context,my_class_name.class);
context.startActivity(I);
}
Let me know if this helps!! or you any issues!!
@@shoebnayeem4104 For those who want to know. Here's how you do it: first you add a global context variable inside the public class like this
"Context context_var_name;"
then in the "onPostExecute" method you write this code:
if(result.equals("login success")) {
Intent I = new Intent(context,my_class_name.class);
context.startActivity(I);
}
Let me know if this helps!! or you any issues!!
@@bhavinpanchani7090 hi , it’s don’t work. Help me please 😢
thank u , the code is working perfectly
send code in .txt armananso@gmail.com
Thank you so much for this tutorial, I was looking for this.
Good video, but needs more explanation of what's going on. This is more like copy and pasting what you are doing. What does aVoid for input parameter do?
Thanq for this great video very helpfull... its working fine i just make changes in it that when user-&-password will correct it will open a new activity bt.. their im getting trouble in fetching data on the new activity ! how to show the data i.e., name of the user on new activity ?
Great ..
I am facing problem of unfortunately stopped app !!
mee too
Thanku for the video tutorials. Sir can you create a tutorial or continuation wherein after successful login you will be redirect to another class which for example user profile.
Late reply! But might be useful for others! When you click on the login button you have to use an "intent", to take you to user profile activity. This video- th-cam.com/video/bgIUdb-7Rqo/w-d-xo.html can help you.
its worked thanks
which version of android u r using sir ?
Hi, I am using Android studio 3.1.3 version. I texted entire code as you explained. When I am running the app in api 24, its working fine. But when I am trying to run in marshmallow or kitkat or any other version its not working after clicking on button(Stopped & closing app). Plz tell me if any libraries to add in the dependencies. Thank you.
can i use xampp as the web server ? are the configurations i needed to set are same just like using wamp server u just shown in the video?
Do uh get any answer for this....Is it same...?
thank you very much
Hi guys! For all those using their phones and to run the app and always gets a "Login Status" but no result message, I kinda have figured it out, for my case though. I ran through the app reading it line by line and found out my error was in a.) conn.php file, my table name was wrong and b.) if(type.equals("login") was written as if(type.equals("Login"), which is wrong. I changed the L to small l and along with the php script correction, it worked.
Which URL address did you use?
The same one he used. Just had to correct the table name from L to small l.
podster12II What was it again?
thank you podster1211, the same case for me, I changed Login to login
first of thank you sir,
sir my code and everything is ok done...
if login is success then how to change Activity?
+Priyank Vadariya were you able to solve the problem?
+Asadujjaman Shohan Yes, if i can solve any problem
can i help you?
+Priyank Vadariya have you solved the problem? because i have the same... I didn't know how to change Activity if succes is ok
+Rafiatou BIRAMAH
remove alertdialog.show();
and put condition like this
// alertDialog.show();
if (result.contentEquals("done")) {
Intent intent = new Intent(getApplicationContext(), Home.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//intent.putExtra("key", email);
getApplicationContext().startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "Email or password is wrong", Toast.LENGTH_SHORT).show();
}
enjoy :)
+Priyank Vadariya i get error, cannot resolve getApplicationContext()
How to resolve that ?
very great tutorial
though I have a question... I have created several cases in the switch statement and they work just fine but how do I add ProgressDialogs for specific cases?? thanks
For login_url if you have a web host would you just use the http of the web host to connect? For example my login.php is located at digdug.cs.emerson.edu/ext/login.php
Would I set login_url equal to that to get the right input or no?