0

Собственно проблема заключается в том что запрос отправляется но без параметров, а именно пустая ссылка http://mysite.ru/file.php а нужно чтобы и параметр name так же отправлялся.

Заранее спасибо.

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://mysite.ru/file.php");

    try {           
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("name", "nameuser"));      
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = httpclient.execute(httppost);

        String responseString = new String();
        HttpEntity responseEntity = response.getEntity();
        if(responseEntity!=null) {
        responseString = EntityUtils.toString(responseEntity);
        }          
        Toast.makeText(getApplicationContext(), responseString, Toast.LENGTH_LONG).show();

    } catch (ClientProtocolException e) {
        // Ошибка :(
    } catch (IOException e) {
        // Ошибка :(
    }

Добавлено:
Решено дело оказалось в файле.

1 ответ 1

1

в file.php смОтрите $_GET вместо $_POST ?

1
  • Действительно дело оказалось в файле, все работает, спасибо.
    – iRusel
    2 окт 2013 в 18:31

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.