アイテムid_categoryはサーバーに送信されませんが、他のアイテムは問題なく送信されます。
add.php:
<?php
header("Content-Type: text/html;charset=utf-8");
require_once('../php/mysql_conect.php');
$use_db=mysql_query("use open_service;");
$date=date("Y-m-d");
$time=date("H:i:s");
$insert=mysql_query("insert into records(id_category,name,phone,device_id,address,text,publish_date,publish_time) value('$_POST[id_categoty]','$_POST[name]','$_POST[phone]','$_POST[device_id]','$_POST[address]','$_POST[text]','$date','$time');");
?>
私のコードの一部:
// ID デバイスを取得
*TelephonyManager telMgr=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String device_id = telMgr.getDeviceId().toString(); name_post = name.getText().toString(); phone_post=phone.getText().toString(); address_post=address.getText().toString(); comment_post=comment.getText().toString(); String id_category="1"; // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter("http.protocol.version",
HttpVersion.HTTP_1_1); httpclient.getParams().setParameter("http.socket.timeout", new Integer(2000)); httpclient.getParams().setParameter("http.protocol.content-charset", "UTF-8"); HttpPost httppost = new HttpPost("http://10.100.100.20/test/mobile/add.php");
try { // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(6); nameValuePairs.add(new BasicNameValuePair("name", name_post)); nameValuePairs.add(new BasicNameValuePair("phone", phone_post)); nameValuePairs.add(new BasicNameValuePair("address", address_post)); nameValuePairs.add(new BasicNameValuePair("text", comment_post)); nameValuePairs.add(new BasicNameValuePair("device_id", device_id)); nameValuePairs.add(new BasicNameValuePair("id_category", id_category));<--It's don send to
サーバー httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
response = httpclient.execute(httppost); //Создаем уведомление Toast toast=Toast.makeText(getBaseContext(), "Заявка успешно отправлена", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, -200); toast.show(); //Возвращаемся а предыдущие Activity Intent intent= new Intent(); intent.setClass(getApplicationContext(), EservisActivity.class); startActivity(intent); }*