Android MySQL Database Tutorial 2 - Android Login with PHP MySQL

Android MySQL Database Tutorial 2 - Android Login with PHP MySQL


Code - http://programmingknowledgeblog.blogs...


Searches related to android mysql login
android mysql server
android mysql client
android mysql app
android mysql php json
android php mysql json login
How to create Simple Login form using php in android
Android Login and Registration with Php and Mysql
PHP Android Tutorial Part
Android Login and Registration with PHP, MySQL
android php mysql sample code
android php mysql json tutorial
android studio mysql connection
Closed Caption:

hello guys welcome to the next video on
Android my school database tutorial for
beginners in the last video i'm showing
you how you can download and install amp
so and how you can create your first
mysql database using PHP my admin and
how you can write a PHP script to
connect to your mysql database now in
this video we will see how we can create
a closed
android application which can interact
with this my school database so let's
get started just fire up your AdWords to
you
ID and we are going to start a new
android project and for example we will
name it as my SQL project guess so MySQL
demo
ok and I'm going to click Next and leave
everything as default blank activity and
me an activity and finish
so now i will project is created and in
this project in this activity what we
are going to do is we're going to design
our login activity right so what we are
going to do is we are going to take some
added text to take a plane and added
text for example for the person's name
and take a password
I detects from here also ok now what we
are going to do is we're going to take
one button and we will name the text of
this button as login
ok so just write log in button and we
can change the name of this button as
for example BTW and log it right and for
the added text
what we're going to do is we are going
to change the ID or of this added text
as for example ET ET use early
ok it to use a name and for the password
field we are going to change its ID as
ET password
ok and I'm going to leave this user name
text as blank
so this is a simple design we want to
give the user name and password that we
click login
it's going to interact with our MySQL
database and that now we want to you
know validate our activity right so now
what we're going to do is we're going to
go to our main activity . java file and
in here
what we're going to do is we will just
remove these two methods area because we
don't need it right now and in here
first to fall at the top we will define
added text variable so just to find that
added text and the define to add the
text variable one for username and one
for a password
so you can just say use a name
ET and the password
ET right for added text now what we're
going to do is we will initiate these
added text with our added tax so just
right
username is equal to in the bracket we
will type cast added text as we always
do so destroyed and it texts at that
white the view my ID
and that are . ID . you are added text
ID right so our added text ID was user
name right
same we will do for the password so i
will just copy it paste it here and this
time i will take the password and in
here we will take ET password right so
just use ET password here now what we're
going to do is we will just once again
02 / main activity not xml file and
India go to text and in the button in
here we will define on
click methods just right on click and
let's say it's on the login method
ok so we want to create a method called
or login
but we press the button we want to
execute this method so just right
public wide or login and that in the
parametres just pass
view and then once again view and inside
your method what we are going to do is
we will take these
username and password and get the text
from these
you know added tax right so we will
declare a string variable string user
name is equal to our user name variable
which is this one . get texts . to
string
ok and saying we will do for the
password so string password
at this time we will take this edit text
password and that we will get the
password from it and save it into a
variable
ok now what we want to do is we want to
validate our username and password and
for that we are going to create a new
class and we will name it as background
Walker let's create onion last year and
we will create a new Java class and we
will name it as background worker and
click ok and we will extend this class
with async task
ok so just extend this class with async
task isn't ask
and as a template parameter here we are
going to give some dummy data types
right now and we're going to change them
in future so for example too wide and
wide and third
also avoid ok and now you can see it
gives us this error and when you click
this bulb or alt enter will ask you to
implement the abstract methods so just
implement this do in background method
and we also want to add some more method
for example on post execute at on
he executes ok supposed to fall on three
execute matter we are going to
add here and then we will add on post
execute and third method we are going to
add here is on progress update
ok and we also want to add a constructor
here because whenever we want to pass
this user name and password
we want to pass it using the background
worker constructor right so first of all
what we are going to do is in the
background worker class we will define
on text variable here
so define our context and name it s
context and now we will define a
constructor so just right
background worker and as a argument we
will pass the context of our class
ok we get name it as C D X for example
rights Oct x
ok and then in here
what we will do we will just assign this
context to our local context right
so with something like this now what we
are going to do is we will go to our
main activity . shower and in the on
login method what we are going to do is
we are going to create an instance of
the background working class
so just right background
walker and that gives the variable name
is equal to you
background worker and it takes the
context right if you remember so context
is this okay and then we can just use
this background loco variable and call a
method called the executable on it and
this will execute the
backgroundworker right so it takes some
argument
so what we can do here is we can pass
multiple argument here
right so let's pass three arguments here
first is the username second is the
possible and third is a type of
operation we want to execute
ok so let's define our third variable
for example string type and we will
define this type as login for now okay
and then we can pass it as a first
argument for example right
it's on you if you want to pass it as a
third argument on the first argument
it's on you but just remember which
argument is it
it is right second is the username and
third is the password
right now it's going to give you this
error because you can see here this is
all three arguments are string and in
the background worker
we have here leave wide so we will just
change this to a string and also this do
it background
this data type will be straight also
right so just change it to string
ok and then you can see the error
available
ok now in here do in background what we
want to do is we want to you know
perform our post operation and that we
want to you know validate our username
and password
so now inside your do in background
mattered what we want to do first is we
want to extract the value of the first
argument which is this type which is
login in our case from this parents
right so what we can do is we can define
a variable called string and limiters
type is equal to its a
parents first index right so just write
parents at index 0
ok something like this and this will
give you the type which is log it right
so now we can just evaluate this type
and if this type equals . equals log in
that we can further write so this is log
in and then all inside our if statement
we can write the code to you know post
some data right
but before that we want to define some
URL
- well you know posed to that URL right
so if you remember we have created this
login dot PHP file right
and whatever we call this fine
music localhost then it's you know
selecting and you know performing the
login function right so we will just
call the same login dot PHP file using
our URL
so you can just tried string and then
log it on the school URL and then just
right
HTTP / and that your IP address
now you may think that here you just it
right
127 . zero . zero . one which is
localhost or you have tonight local host
but what you know after a team or
Android the people has decided that if
you want to communicate with the local
host on your host machine using the
android emulator
then you need to
use the IP which is this one so just use
10 20 . to .
- it's a standard IP address to
communicate with local host right
and that your file in which is login dot
PHP right and then and close this into a
double quotes because it's a string and
then a semi call now inside this if
statement will define our object of your
URL you can just name it as URL is equal
to a new URL and that as argument just
passed our string URL here right now
first of all you need to import this URL
from java.net . you are also order to
enter and then you need to enclose this
URL to the try catch block so you just
need to add it into the try catch block
ok so just how over here and that
click this bowl and then surround with
try catch block
ok now in here just below this we need
to use HTTP URL connection
plus you may be tempted to use HTTP
client to post but you know currently we
use HTTP URL connection so just right
HTTP URL connection and give the
variable in for example HTTP URL
connection is equal to at that you take
this URL at that open connection and you
need to type cast this URL open
connection to HTTP connections so just
use this type casting matter something
like this and then you need to once
again
salon
your code with try catch block so you
already had it
you just need to add one more catch
clause here
ok which is why exception right now you
can take this sash DP connection and
then you can set your request method
first of all our request method will be
post
it's something like rest request
so you just need to write a post here
and then you need to set some more
method for example set output or two
output and make it as true and we also
want to set due in full so just copy
this and instead of two output
you just need to use . set do input
ok now after that we are going to create
an instant door for output stream so
just right output stream and then give
the name to your own stream and we are
going to get our third stream from our
HTTP connection so just take a steamy
connection get output stream and that we
will create an instance of afford writer
ok so just call before word writer and
give the variable name before writer is
equal to know before word writer and it
will take an instance of four output
stream writer so just right output
stream writer and the first drive event
it will take is our output stream and
the second argument is the type of album
stream so we are going to give here
is UTF 4-8 right and then close it and
then we are going to create a war data
URL which we want to post
ok so just right
string and that our post data suggests
right post on the score data and then
you will write URL encoder . and code
so just call and called method here
which is first one and that here you
will just give the you know key and
value pair right so let's say our key is
user name and the value is the username
when right so what we can do here is
first of all we can extract the value of
user name and password which we have
passed using the you know this
background worker
username and password right so we have
already extracted this type using the 0
10 PX of pattern and that we can you
extract username and password using
first and second index so just take this
and then paste it here and this will be
your user on the school name for example
and the second will be the password
password and then this will be our index
1 and this will be next to right now you
can take the same name here which is the
key for your post data and that what we
can do here is first of all we need to
give the data type which is utf-8
regístrate UT have -
it here and then just right
concatenation operator and the double
quotes equal to and make sure that there
is no space between them right
last the value of usernames will just
copy the same thing and paste it here
and then the ending is this one right
without the double quotes right and that
you just use your concatenation operator
once again and then in here you'll add
the ad operator which is for joining the
URL right and then in the next line
what we can do is we can copy the same
thing from here up to here because we
don't want to add right now because it's
to end of the URL and just close it and
this time this will be our password
field so just right password and
password
so this is our post data URL make sure
there is no space here and you have and
here now we just want to write this post
data to the bar for writers to just use
bottle right about right and this post
data will be the argument for this and
that
just use a buffered writer and that
flush everything so just call flush at
that once again
all this while before writer and we will
close it
ok and we also want to close our output
stream so just use our stream . pills
ok now when you post some data on
to the server you can expect some
results also or response also for the
post request and who read this response
from the post weakness
what we can do here is we can once again
the finite input stream and that buffer
reader to you know get the response so
this time we will define our input
stream here so just define income stream
and that the by the millions put stream
and then we can get the input stream
from the same
HTTP connection so just right get in the
stream and once again we will define up
before reader this time so just right
before reader take the variable name is
equal to Nu buffered reader and as the
argument new input stream reader right
so just right
inputstream reader and as an argument
it takes this income stream at the type
of for data at this time
this data which we are expecting is all
for this type which is iso- 8859 - 1:00
and now once we have our response we
want to read it line by line that
makeover response from it right
so
just define two more ready to move one
is a resort for example and other is
string Line to read the line line by
line and just right
while so just add a while loop and we
will you know read the line like my
lights to just use light is equal to
before the reader . read line is not
equal to null is not equal to model that
we can add this line to the response
right or the result suggests rate result
last equals this light
so something like this ok and something
like this and this
all data should be in single bracket so
we are evaluating this and we must also
initialize these when you with them for
example or empty string
ok so just initialize line and result by
empty string
ok and the once a war work is done what
we get do is we can close our buffer
reader so just close after your while
the bufferedreader close and that we
will close our input stream from here
just right in the stream not close and
that we will disconnect from our hdb
connection right so just right
HTTP connection . disconnect
ok and in here now we want to return the
result which we have got right so just
write return result now it's going to
give you this error because our return
type if you can see here is wide here
so change this
return type of this matter do in
background -
string and that this will give you once
again the other because we need to
change this written time from here and
here also straight and the async task
types and also we need to change it here
in here write and post execute right so
just change it here also
ok now to show the login result we need
a a lot box or something like that
so what we can do is we can go at the
top and in here we can define a lot
dialogue and give our variable name for
example a lot dialogue and that press
alt enter to import a lot of dialogue
and that we can initiate this a lot of
dialogue in here we execute method
ok so on a pre execute method you can
just write instead of this light you can
just write a lot of dialogue is equal to
Nu a lot of dialogue . builder
so just right builder and that take the
cause context which we have defined at
the top
so this constructor is taking the
context right so just take this context
from here and pass it here and that .
create
ok so just call a method called . 3 it
and remove these brackets from here
ok and now you can also set some title
to your alot the box
so for example you can see login status
ok so this will be the title of your a
lot box now to show the resulting the
alert dialog what you can do
is you can go to all posts to execute
method and in here you can just remove
this line at this rate string can be
result at that you can take your a lot
dialogue and said the messages are just
right set message and just passed this
result here and that you can show the
message which is coming from the server
right so just write a lot of dialogue .
show
ok so this will show the response of the
soul
so what code is almost done what we need
to do next is we need to go to our
manifest folder here and go to
androidmanifest.xml file and we need to
give the eight different permissions
here above this early application
element so just give this line of code
to allow the internet permission
just add user - permission space android
name is equal to android . permission
not internet and this will add the
internet permission to your android app
one last thing which is remaining is we
need to add it
our
PHP files right so go to the connection
. PHP which we have made and if you
already figured there is the location of
this connection . PHP
it's in your lamp for the nerc directory
and in ww
you can find login dot PHP and the on
dot PHP right which we have made in the
last video
ok so first of all we need to remove
this equal information from here so just
remove these lines of code from if
condition
tell your end of your egg if condition
right in the corner . PHP
ok and save it and in the login dot PHP
we have given this static information to
login
so to have the post
you know request received here
you need to replace this by dollar that
underscore post at that in the square
brackets just use square brackets and
then your key
dam which you have defined it your
Android old right so go to your
background worker and once again check
what is this key value which is user
name here right
the first two key value ok and place it
here and in the same where we will just
place the password key value from here
which is this one in the double chords
right so this is value at the double
calls right so go here at the change it
here also and the save everything and
that then running your bulb
ok so my app is running now and I'm
going to define the username and
password which i have defined it
the database which is one two three and
one two three
so I will give this one two three and
one two three here and when i click
login
it doesn't reply me so this can be the
problem
sometimes if you have this 10.0 point to
point to the IP address defined here in
some cases it will work if you are
connected with local host or if you want
to connect with local host otherwise in
most of the cases it will work
otherwise what you can do is you can
open your rectum our problem so just
open your command prompt here and then
just right
I p on figure so just write ipconfig and
press ENTER and it's going to give you
your IP address of your local network
and as I can see in my case the IP
address here is what might do . 168 .
what not six here right
so you just need to search for wireless
LAN adapter or wide let adopter and
search for this IP address which is the
first address which is what mine too .
168 . what . six right at that replace
this by 192 . 168 . 16 in your case it
can be different so just just see this
value at the best it here
once again we are going to rock our appt
at our app is once again running so once
again i will give one two tree
username and
password one two one two tree at that
click login and now i can see this login
success message which is coming due to
this line of code
okay i can just change this line
blocking success and then some ! and
that some some message long and success
the for example well come use something
like this and then save it and once
again and click the login message and
now you can see login success and
welcome user here
ok so i know that this is coming due to
this and when I gave the wrong username
and password is going to give me long
get success which is this message
ok so in this way you can create a login
page in your Android application using
mysql database
i will also you know give this code in
the description so you can you know
copy the same code and the pisted into
your application and tested
ok so just click the link in the
description and you will get the call
from there
so please read it and subscribe bye for
now

Video Length: 33:55
Uploaded By: ProgrammingKnowledge
Published: 1/7/2016
View Count: 421,124

Related Software Products
Web Log DB
Web Log DB

Published By:
ExactTrend

Description:
The Web Log DB exports web log data to databases via ODBC. Web Log DB uses ODBC to export data from raw log files to your database, using SQL queries. Web Log DB allows you to use the applications you have become accustomed to such as MS SQL, MS Excel, MS Access etc. Also, any other ODBC compliant application can now be used to produce the output you desire. Use Web Log DB to perform further analysis in special softs. Web Log DB supports more than 25 log file formats. It was tested with all ...


Related Videos
ASP.NET Tutorial 3- How to Create a Login website - Creating Database For website
ASP.NET Tutorial 3- How to Create a Login website - Creating Database For website

Video Length: 13:42
Uploaded By: ProgrammingKnowledge (12/13/2013)
View Count: 571,191

ASP.NET Tutorial 4- How to Create a Login website - Connecting Database to Registration Page
ASP.NET Tutorial 4- How to Create a Login website - Connecting Database to Registration Page

Video Length: 25:50
Uploaded By: ProgrammingKnowledge (12/14/2013)
View Count: 458,272

Java prog#3. Login Program for java with sqlite [ Mysql ] database PART-1
Java prog#3. Login Program for java with sqlite [ Mysql ] database PART-1

Video Length: 10:01
Uploaded By: ProgrammingKnowledge (4/22/2012)
View Count: 446,287

PHP Tutorials: Register & Login (Part 1): Database
PHP Tutorials: Register & Login (Part 1): Database

Video Length: 08:58
Uploaded By: Codecourse (5/11/2012)
View Count: 330,974

ASP.NET Tutorial 6- Create a Login website - Login page & Validating User and Password in database
ASP.NET Tutorial 6- Create a Login website - Login page & Validating User and Password in database

Video Length: 22:58
Uploaded By: ProgrammingKnowledge
View Count: 300,093

Login system using PHP with MYSQL database
Login system using PHP with MYSQL database

Video Length: 18:30
Uploaded By: Awa Melvine
View Count: 249,133

ASP.NET Web Forms website Part 1 - Connect with MySQL database connection
ASP.NET Web Forms website Part 1 - Connect with MySQL database connection

Video Length: 45:40
Uploaded By: Chris Duran (8/20/2014)
View Count: 234,124

C# MS Access Database Tutorial 2 # Create Login Form with Microsoft  Access Database
C# MS Access Database Tutorial 2 # Create Login Form with Microsoft Access Database

Video Length: 24:20
Uploaded By: ProgrammingKnowledge (7/13/2014)
View Count: 229,089

Netbeans Java Login Application + MySQL
Netbeans Java Login Application + MySQL

Video Length: 28:48
Uploaded By: Fajar Sebastian
View Count: 150,771

How to Create Login Form using vb.net and SqlServer Database
How to Create Login Form using vb.net and SqlServer Database

Video Length: 05:11
Uploaded By: GeeksProgramming (11/11/2013)
View Count: 123,862

Copyright © 2026, Ivertech. All rights reserved.