Summary -I take text from edittext and send it to server. And server put these strings to text file -There is no visible error. -Server gets my post but it has onyl null string.
Here is my post code
public void onClick(View v) {
new AlertDialog.Builder(GorusHataBildirimActivity.this)
.setTitle("Bildirim Yola")
.setMessage("Bildirim yollamak istiyor musunuz ?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Thread thread = new Thread(new Runnable(){
@Override
public void run() {
try {
EditText isim = (EditText) findViewById(R.id.editText);
EditText email = (EditText) findViewById(R.id.editText2);
EditText mesaj = (EditText) findViewById(R.id.editText3);
CheckBox checkBox1 = (CheckBox) findViewById(R.id.checkBox);
CheckBox checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
String a = isim.getText().toString();
String b = email.getText().toString();
String c = mesaj.getText().toString();
String s = "Debug-infos:";
String k = "Debug-infos:";
if (checkBox1.isChecked()) {
s += "
OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")" + "
OS API Level: " + android.os.Build.VERSION.SDK_INT;
}else {
s= "0";
}
if (checkBox2.isChecked()) {
k += "
Device: " + android.os.Build.DEVICE + "
Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
}else {
k = "0";
}
HttpClient client=new DefaultHttpClient();
HttpPost getMethod=new HttpPost("http: my url /bildirimler/bildirim.php");
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("isim","dsa"));
nameValuePairs.add(new BasicNameValuePair("email",b));
nameValuePairs.add(new BasicNameValuePair("mesaj",c));
nameValuePairs.add(new BasicNameValuePair("d1",s));
nameValuePairs.add(new BasicNameValuePair("d2",k));
getMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
client.execute(getMethod);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
i think this code (android side ) does not work correctly.
here is php code
<?php
$dateFile = date('d-m-Y_hia').".txt";
$dataString = "isim:" . $isim . "mail:" . $mail. "mesaj:" . $mesaj. "d1:" . $d1. "d2:" . $d2. "
";
$fWrite = fopen($dateFile,"a");
$wrote = fwrite($fWrite, $dataString);
fclose($fWrite);
print "file created and written to";
?>
Moreover ,
nameValuePairs.add(new BasicNameValuePair("isim","dsa"));
in there i used "dsa" instead of using string name like a b c ( my strings in my code ) but stil doesnt work.
my output file is like "isim:mail:mesaj:d1:d2:"