Login And SignUp In Android With MySQL (Updated Oct, 2021)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] in this video we'll be seeing how to create a login and sign up system in Android this is the demo of the application that we are going to create after entering all the details click sign up now the sign up is successfully completed and we are redirected to the login page now let's enter the username and password and try to login now click login and we have successfully logged in and this is the application that we are going to create in this video and this video is going to be somewhat long so let's get started first of all we require samp for Apache and MySQL so download the latest version of samp and finish the setup I have samp and let's start apache and mysql then go to the PHP my admin you can just click the admin button from here and then we have to create a new database or the project for that just click the new here and give the name for the database and then click create now we have created the database now we need a table to which we are storing the data so I am using the name user so that we are storing the user details into the table and we require right now we require five columns and click go now on the first place we have to add an ID then we need full name then we need user name then we need password and email now ID is int and we have to set it to auto increment then we have to change the type of full name to text and username to war care of 300 and password to text and email to work here of 300 actually username just require 100 I think so now we need to make sure that username and email must be unique so choose unique here click go and then email make it unique ok now the ID is primary key and user name and password are unique after that click Save now we have our table ready we have ID full name username password and email now let's go to the PHP part will be using PHP api's to make the interactions with MySQL database so go to this github repository and download this files and unzip it now we need these four files now this files could make the work a lot easier we have to keep this inside HTTP dogs inside the samp so go to the exam control panel and click the Explorer from here and then select HTTP dogs now here create a new folder and name it now after naming it we have to copy the files from the Downloads to this folder we don't require the read MD fire so avoid it and paste the rest inside the log in our log in this folder which is the project me I have given and after that let's open this project inside an ID and I am using phpstorm you can use anything like vs cord or anything that you like I'm using phpstorm so let's open the project so now how open the project inside phpstorm and we need to change database config dot PHP file and as we are using the samp server name is localhost and username and password by default we have root and also password which is empty which is by default inside there inside the sap you can add any new user or use the default one now we have to change the database name we have created a new database that is logging register so just change the database name and save it now what this login dot PHP does is it makes sure that the user name and password matches the username and password in the table and sign up does is just inserts the user name full name email and password to the table and now just go to the repository now here we have functions name login which accepts the table name username and password as parameters and sign up accepts table name full name username password and email as parameters so here I have passed the table name full name email username and password into the function signup so inside the signup we just do some security stuffs and after that we inserts the value to the table name and we have passed the table name as users which is our table name which we have created here okay you can change the table name and anything as you wish okay I have used it like this so this is what the PHP caused us you can just simply go to the repository and download it and this could make the work a lot easier so if the sign of peace access would it returns signup successful if database connection fades it returns the error if signup waves it returns sign of fail and like that and the login also works exactly like that if login pales it returns username or password wrong if data bits database connection fails it returns database connection error and that's how this works if you simply go and check this login dot PHP it shows all fields are required this means that you haven't set the post variable username and password here we are checking whether the username and password is set now ESET does that hope you knows the basics of PHP otherwise this is gonna be a little bit difficult for you still you can do it along with me and now let's go to the and droid implementation first of all we need to design the UI login UI and then get to the Java part now open the Android studio and create a new Android studio project I'm using the empty activity now give the application a name and you can change the package name and all and just click finish now after completely building the project you have to go to resources layout main activity dot XML and we are not going to do anything much here first of all we have to create a new activity empty activity and name it sign up now we'll be creating our sign up in a new activity and also we have to create a new activity for Loki now I will show you how to create the design for just one of the activities and I'll be showing it for the login and then I will provide the rest of the source code on the description you can download the source code and the steps for both are almost the same so there's no need to show both and make this video longer first of all go to project structure dependencies and add a library dependency search for material and add the first one and click OK you then go to the repository that I have given the link in the description this is one of my github repository this makes HTTP URL connection a little bit more easier and I go to this URL and we have to add the suppository dependency just copy this line and add it on the route graded file go to cradle scripts and this one this is the root Gradle file add it inside here then copy this line which is the dependency and add it inside build.gradle app module place it here and then click sync now now all the files are downloaded and synchronized to the project I'll go to the split mode and add a text input layout inside that Adhan text input edit text here give a hint like username and we have to add it as a string the sisty that is the best preferred way to just hope tender and click OK now it adds the string username inside the Piatt string dot XML you can see that now we have added a field before you see me now we have to add another field for password now we have added both the fields but they are not visible properly that's because this is a constrained layout and we haven't given the constraints for thee we used to be aligned in properly so just go to the design and in the component key select the first text input layout and then just drag at down and also changes just make the Ordos corrupt okay and just keep them properly after that just give the constraints you then again abnesti placement now this will not go from here now again the same for password now you can see that the password field is constrained to the username field now if you move the username field the password field also moves without changing the distance between them now that's the use of constrain the ordinal just giving it a margin left and right now add a text log in here now we have to add the constraints you you just keep the gravity to Center now change the text size now go to the resources that have provided in the description and download it and copy the font folder how kept two phones inside it and just paste it inside their sources folder now you can see two forms are added now come to the text view and say in the font family and that's it now I'll do that the same for edit text also now we need to add a button on the bottom for that create a button and style equal to button colored and that will make this cool design or the button and to the text login keep button and give the gun chains now we have to add to troubled files vector assets and then search for pull some and add it now we will use it for username [Music] here add trouble left right and you choose the trouble that we have added now you can see an icon has appeared in the right and do the same for password you now our login form is ready now go to the colors and change the color ancient to and sin to the screen that looks a little bit more nice and also change the text few color to the same color okay now this looks a little bit neat and clean and similarly you have to design the signup form also I have already created it and it's provided in the description refer it and do the same you now how Korea completely created the sign up and log in UI now I have given the source code so you can just refer and do it by user and this is the both device this is for login and this is for sign up we are accepting full name email username and password for sign up and in login we are accepting username and password and doing the rest in our PHP API now go to the repository advanced HTTP connection and then here we are having two classes that is fetch data and put data and we need put data so go to the put datum class and here we are having some this is here we are creating the parameters that are to be passed to the post or get in PHP and this is the name of the parameter or the field field name and this is the data and this is how it is now if we are accepting a post with param with field name that is param 1 then we have to create the array like this the data will be like this and this data won't be received here in this post variable and if you did understand it let's do it and I hope you will understand it now we have to create object for put data before that this is the entire code we need to implement so let's copy this and go to sign up first and inside here just paste it and press alt enter and import now we have we need the handler Android OS ok import that and put data import the class and we don't need the log just remove it now in sign up we are passing full name email and username and password so just change this to full name username password and email and we have to change the array size to 4 since we have 4 variables and change it to 2 and 3 now our array for the field name is ready now you have to do the same for data now we have to get the data from the edit text that we have kept inside the signup form so we have to give IDs for all these so I have given the ID for full name as ID equal to full name and for email I have given the ID email for username as username and for password its password also for the sign up button it's sign up button sign up okay now also for the login that's login text okay we have to make sure the ID is correct then go to the signup Java part and we have to any slice all those here create the object for them you now we have declared objects for or the edit text and button sign up button and also for the login text on the bottom and we have to initialize it with the views and connect it so for that you now we have to add an onclicklistener for the button sign up inside here we have to perform these actions so cut it from the and paste it inside the on click method now we have to get these value get the data values from the text views for that create four strings now we have to get the value from edittext now we receive the value full name from the error text now we have to do it for rest of the retest now we have to check whether there is a value typed inside the edit text all these fields for that create an if condition and check with a full name but not full name dot equals empty and and okay use name dot equals empty and do that all rest of the field also and open the brackets and close it here and here we have to create an else and and create a cost saying all fields are required now if the there is if there is no value inside the textview all four of them then this dose will be shown if there is value in all these four text views edit text then this will be executed now instead of this data one we have to change into full name username password and email now we have created the array properly now we have to is the URL to the one we have created here for the signup this is the URL and the URL will be like localhost project name folder then sign up dot PHP it will be inside the folder where you have kept it so find the URL it will be if you followed me then it will be like localhost / project knee then the signup dot PHP now change the URL now we cannot keep this as localhost because if you are trying it in our mobile phone then we cannot access it like localhost because that would not be localhost for the mobile device for that you need a Wi-Fi connection or something in order to keep the connection between your laptop Apache and the Sam connection with the mobile so type CMD and check the IP config and this is the IP for the device right now so copy it and change localhost to this now if we view this URL you can see that this also takes you to the same page now the difference is that you can view this from any other device which is connected to the same Wi-Fi connection that you have okay then here we need to do some changes like add the progress bar visibility and after that here will be getting the result and we need to manage the result also here inside the result we can check it as if result dot equals equals sign of success because if they sign up is success we are returning this so check it and let's show it toast message and toast message let's show the result as the toast in the show okay now here we have to create an intent intent now what does this does is if signup is successful then it opens login activity and the login form will appear if it failed then it shows a toast message with the result in it so let's show our toast here also okay now it shows the toast message when the signup is successful also now let's add the progress part for this Annette I have added the progress bar here again refer the code which is given in the description and the idea is progress create an object for the progress bar initialize it and then set the visibility here make the visibility to visible here and visibility to go on here on complete now the signup part is completed now this is the code for signup I think we have completely finished a sign-up pot let's just run the application and check it if you are using the internet connection you just have to add the user permission for internet also if you're using you know if you're using a URL which is not the couple hosts then you need it now we haven't set the signup activity to be the launcher so that's what happened here let's change this just cut this and go to the signup and paste it here and now we'll just launch it now the signup ass came now you can see the action bar is visible there now we have to change it for that just inside the manifest file just keep these team to just keep the team to this and that will be fixed now the signup doesn't have the action bar also and now let's try creating the account you let's just click sign up now you can see an error now this error occurs because we are not using the HTTP yes connection and to ignore that you have to give this attribute to the manifest file and this run it again now this is going to solve the problem now let's add the e details again sign up now sign up is successful and we are redirected to login page let's go to the PHP my admin and check our database and you can see the username and password and the details we have given is present inside the table users now the signup is completed and now we have to deal with e logging now log in is almost like the sign up and we don't have we just have to remove two fields from that that's hope so let's go and do it now open the login dot Java file and we have to initialize all the things just like this I'm just copying it and we don't require full name and email okay now but then sign up should be like logging then text should be like sign up and that's it after that you have to initialize the objects now you have to make sure the IDs are correct okay you have to use the same ID that you have given in the activity log in XML file and the Java which we are calling inside the find view by ID are same okay don't just get confused with the ID inside sign up and login don't just mix it you can always keep it like give a an extension like login and also give it like for signup you can give that username sign up etc that's a good way to avoid your confusion and do that and just finish this you now we have to give the onclicklistener for the button just like before you can just copy all discs till here and just paste it inside here and change the button object name also we don't record the full name and email remove them from the if condition also and the modem from the array also reduce the array size to to also change number now here you have to change the URL and the URL is this one okay copy it and I play this out to change it to login okay now the URL is changed and here we have to change the result is blocking success now change it and that's it now we have to change the intent to main activity third class because if the login is successful we have to open the main activity class and that is this one and let's add message welcome here and that's it and just keep the bonsai text sighs - so TSP and also change the font family yes for okay that's it now if the login is successful it opens this page okay - okay now the login is also complete and go to the manifest and do the now on the manifest you have to cut this from here now here we have to set an onclicklistener for this textview so that anyone have to have an already have an account and have to log in they could click here and open the login page and same here if anybody have to create a new account they could click here and go to the signup page and for that we have to set an onclicklistener for the textview let's set it for the signup first and the textview is this one okay so to set on click listener now here we have to create an indent to open login so we have to keep it to log in class and start the activity in them and just finish it and that's it now we have to do the same on the login also so we'll just go to here and paste it here and change the object name and also change the class to sign up now go to the manifest and we have to change this to cut this from here and we have to keep this in the log in because logging should be shown first and also change the theme of Logan our device you will see the action bar again okay now that's it we are almost done now let's launch the application now I think the application crashed and that's because of the button here okay and yes we have it yes we have choose the wrong button ID here I told you not to and I made mistake okay just change the button ID okay that's plus the error this make sure the IDS are from the exact layout okay I just made a mistake there okay now you can see the login page is ready and also when we click the sign up sign up form appears that's it now let's login with the credentials that we created before and password and click login now login is successful and the activity opened and now hope you understand how to create this login form it was a quite a long video but I think I explained all these crucial things now this is how you can create a login form also if you check this username you can see that we are verifying this username and this password and this password is an hash the form so we cannot actually know the password after the user inserted this and if you want to if you want to just change the password type 2 password so that the others will not see what we are typing and this input type 2 password text password now what this does is when we type the field will show just dots instead of the text like this you can see and this is the password you can just do that the same for the signup also now hope you understand how to create a login and signup form by using the MySQL database and hope you understand all the concepts if you have any doubts you can leave a comment or join our whatsapp group or anywhere and I will be responding to your doubts and if you liked the video give it a thumbs up and subscribe to our channel for more such videos
Info
Channel: Codes Easy
Views: 192,909
Rating: undefined out of 5
Keywords: login and signup in android, login and signup in android with mysql, android mysql, login in android studio using mysql, login android studio mysql, login and signup in android studio with database, android login and registration with php mysql, login and signup in android studio, login in android, android login, signin and signup android studio, Android php mysql, login and register android studio, Login and register in android studio, android registration, Codeseasy
Id: X8oD4q3XtQQ
Channel Id: undefined
Length: 57min 21sec (3441 seconds)
Published: Thu Jul 02 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.