3

Hi im new to both android and java

i have php page in my webserver, i want to get this page result in android. I have search a lot for mysql android connection someone says that it is possible through "new URL" in java. But i cannot catch this method. Actually i want to implement a login page for android. I have already created a login page in php. Now i want to just post username and password value to php page the php page will check the data with database and if user is a valid user i need to redirect otherwise i will show an error message.

thanks

user359187
  • 2,269
  • 6
  • 29
  • 44

2 Answers2

9

You should consider writing an API on your webserver that returns JSON data to your client.

Then for example you would call the php page http://yourwebsite.com/api.php?method=login&username=user&password=md5password

The webpage would then return a JSON data result that your Android app can parse for a result (200 success, 403 access forbidden if they entered a wrong username or password, etc. etc.).

An example. And here is another.

Bryan Denny
  • 27,363
  • 32
  • 109
  • 125
  • This is definitely the best way to do it. RDBMS connectors are big and bulky. Make a REST API on top of your resources, and then all you have to do is write a very small language binder for your API in Java. Language binder = small, db connector = big/overkill – kmarks2 Nov 12 '10 at 16:25
  • `An example` link is broken – Gibbs Apr 05 '16 at 08:30
  • Thanks @BryanDenny – Gibbs Apr 06 '16 at 03:52
0

An other approach is to use a Virtual JDBC Driver that uses a three-tier architecture: your JDBC code is sent through HTTP to a remote Servlet that filters the JDBC code (configuration & security) before passing it to the MySql JDBC Driver. The result is sent you back through HTTP. There are some free software that use this technique. Just Google " Android JDBC Driver over HTTP".

kaw
  • 77
  • 1
  • 4