Click here to Skip to main content
15,925,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have successfully sent 2 strings to my online php server (000webhost.com)
by using this code

public class BackgroundWorker extends AsyncTask<String,Void,String> {
    Context context;
    AlertDialog alertDialog;
    BackgroundWorker (Context ctx) {
        context = ctx;
    }
    @Override
    public String doInBackground(String... params) {

String login_url = "ssdsad^%&^&(#^&^(())_).com/xyz.php";
               String name = params[1];
               String password = params[2];
               URL url = new URL(login_url);
               HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
               httpURLConnection.setRequestMethod("POST");
               httpURLConnection.setDoOutput(true);
               httpURLConnection.setDoInput(true);
               OutputStream outputStream = httpURLConnection.getOutputStream();
               BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
               String post_data = URLEncoder.encode("name","UTF-8")+"="+URLEncoder.encode(name,"UTF-8")+"&"
                       +URLEncoder.encode("password","UTF-8")+"="+ URLEncoder.encode(password,"UTF-8");
               bufferedWriter.write(post_data);
               bufferedWriter.flush();
               bufferedWriter.close();
               outputStream.close();
               InputStream inputStream = httpURLConnection.getInputStream();
               BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
               String result="";
               String line="";
               while((line = bufferedReader.readLine())!= null) {
                   result += line;
               }
               bufferedReader.close();
               inputStream.close();
               httpURLConnection.disconnect();
               return result;
           } catch (IOException e) {
               e.printStackTrace();
           }


What I have tried:

now i want to send a string array
how can i achieve it successfully to my my php server and what php code should i use to access that array??
Posted
Comments
David Crow 22-Aug-17 10:38am    
Have you considered asking these type of questions in the actual Android forum?
chinu1d 22-Aug-17 11:00am    
no but did'nt anyone try it before?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900