I'm a new comer to android development and, I wish to develop a credit card applicatoin for android, which will send data to my website, (for instance longitude &lifier latitude), my question is how you can send data from android and just how to obtainOrcatch it on website.
This may help. Just a good example Used to do not long ago delivering acceleration data to server and so i could keep data right into a mysql database. To transmit data to server you could do this this:
private void sendData(ArrayList<NameValuePair> data) Scribe data. 3) Send data. try world wide web.blah.com/AddAccelerationData.php") httppost.setEntity(new UrlEncodedFormEntity(data)) HttpResponse response = httpclient.execute(httppost) Log.i("postData", response.getStatusLine().toString()) //Could make a move better with response. catch(Exception e)
then to transmit allows say:
private void sendAccelerationData(String userIDArg, String dateArg, String timeArg, String timeStamp, String accelX, String accelY, String accelZ)
so then your AddAccelerationData.php file on server is:
<?php /* * What this file does could it be: * 1) Produces link with database. * 2) Retrieve the information being send. * 3) Add the retrieved data to database. * 4) Close database connection. */ require_once '../Connection.php' //connect with a database/disconnect handler. require_once '../SendAPI.php' //handles delivering querys. $server = new Connection() $send = new Send() //Connect with database. $server->connectDB() //Retrieve the information. $userID = $_Publish['userID'] $date = $_Publish['date'] $time = $_Publish['time'] $accelX = $_Publish['accelX'] $accelY = $_Publish['accelY'] $accelZ = $_Publish['accelZ'] //Add data to database. //Personal approach to query and increase database. $send->sendAccelerationData($userID, $date, $time, $timeStamp, $accelX, $accelY, $accelZ) //Disconnect from database. $server->disconnectDB() ?>
It is really an example I made use of lately. Simply to note within the php file. I import Connection.php this just handles the bond towards the database. So just replace by using your code for hooking up to MYSQL db. Also I imported SendAPI.php (which you'll just ignore)It was just my class for delivering data. Essentially it contained a few of the querys I needed to make use of. For example sendAccelerationData(). Essentially class looked like those of saved methods.