• 0

double data posting


Question

hello I cant work out how to post two bits of data to a PHP script ... I can post one name pair but the other one just adds on to the other and does not become its own post value ... how would i go about this?

 

small snippet below

 

 

String data = (URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8")) + (URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"));
    URLConnection connection = url.openConnection();
    ((HttpURLConnection)connection).setRequestMethod("POST");
 
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

 

hello I cant work out how to post two bits of data to a PHP script ... I can post one name pair but the other one just adds on to the other and does not become its own post value ... how would i go about this?

 

small snippet below

 

 

String data = (URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8")) + (URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"));
    URLConnection connection = url.openConnection();
    ((HttpURLConnection)connection).setRequestMethod("POST");

 

 

add an "&" inbetween the two? Note, i didn't actually check this.

 

I.e. 

String data = (URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8")) + "&" + (URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"));
Link to comment
Share on other sites

  • 0

 

add an "&" inbetween the two? Note, i didn't actually check this.

 

I.e. 

String data = (URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8")) + "&" + (URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"));

 

 

hmm maybe ok il give it a go xD might have been the mistke i made 

Link to comment
Share on other sites

This topic is now closed to further replies.