Jump to content



Photo

double data posting

java

  • Please log in to reply
4 replies to this topic

#1 Original Poster

Original Poster

    Systems Developer

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7/8, Kali, ubuntu, OSx 10.9
  • Phone: Android

Posted 06 December 2013 - 16:46

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");
 



#2 +snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 06 December 2013 - 16:49

 

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"));


#3 OP Original Poster

Original Poster

    Systems Developer

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7/8, Kali, ubuntu, OSx 10.9
  • Phone: Android

Posted 06 December 2013 - 17:04

 

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 



#4 firey

firey

    F͎̗͉͎͈͑͡ȉ͎̣̐́ṙ͖̺͕͙̓̌è̤̞͉̟̲͇̍̍̾̓ͥͅy͓̍̎̌̏̒

  • Tech Issues Solved: 8
  • Joined: 30-October 05
  • Location: Alberta, Canada
  • OS: Windows 7
  • Phone: Android (4.4.2)

Posted 06 December 2013 - 17:09



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


Would make sense. PHP's $_GET['field']  would look like [url]?param1=value&param2=value&....



#5 +snaphat (Myles Landwehr)

snaphat (Myles Landwehr)

    Electrical & Computer Engineer

  • Tech Issues Solved: 29
  • Joined: 23-August 05
  • OS: Win/Lin/Bsd/Osx
  • Phone: dumb phone

Posted 06 December 2013 - 17:14




Would make sense. PHP's $_GET['field']  would look like [url]?param1=value&param2=value&....

 

Yup, that was my impression as well