1

I am really confused about how to send data from my android app to a website. I am thinking of using php to get data from android and send data to the html page. I am aware of sending data through php to a mysql server. I am unsure about the php and html file that I have to develop here. I need the data to be displayed in some textbox in my html page.

Is there any other way to do this?

2 Answers 2

1

I am not sure what you mean by sending data to HTML page from php, html can not recieve data. Instead you can use a php page to do it.

Android code:

HttpPost httppost = new HttpPost("PHP_PAGE_ADDRESS");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("data", "abc"));
nameValuePairs.add(new BasicNameValuePair("data1", "def"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);

PHP Code:

<?php
$data =$_GET['data'];
$data1 = $_GET['data1'];
?>
<form>
Data: <input type="text" name="firstname" value = <?php echo $data; ?> ><br>
Data1: <input type="text" name="firstname" value = <?php echo $data1; ?> >
</form>

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

0

Try to send your data in json format. Actually i am not aware of android app. But i think it is possible to send data in json format and you can easily receive in php by

json_decode($encoded_json_var);

1 Comment

Yes i know how to receive data in php from android. What i want is how to send this data in php to a html form???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.