My php file :
if(isset($_POST['eposta'])&&isset($_POST['sifre']))//uygulamadan gelen verileri kontrol etme
{
$eposta = $_POST['eposta'];//gelen eposta yı alma
$sifre = $_POST['sifre'];//gelen sifreyi alma
require("ayar.php");//Ayar dosyasını içe aktarma
$sorgu = mysql_query("Select * From Kullanici Where Eposta='$eposta' AND Sifre='$sifre'");//gelen sifre ve epostayı kontrol etme
header("Content-type: application/json");//JSON Tipi yapma
if($oku = mysql_fetch_array($sorgu))//gelen sifre ve epostayı kontrol etme
{
$data[] = array(
"islem" => true
);
}
else
{
$data[] = array(
"islem" => false
);
}
echo json_encode($data);
}
My android file :
HttpPost post = new HttpPost("http://www.tutaret.tk/not/mobil_giris.php");
List<NameValuePair> gonderilenler = new ArrayList<NameValuePair>(2);
gonderilenler.add(new BasicNameValuePair("eposta",eposta.getText().toString()));
gonderilenler.add(new BasicNameValuePair("sifre",sifre.getText().toString()));
post.setEntity(new UrlEncodedFormEntity(gonderilenler,"UTF_8"));
HttpResponse response = client.execute(post);
if(response!=null)
{
InputStream in = response.getEntity().getContent();
BufferedReader oku = new BufferedReader(new InputStreamReader(in));
StringBuilder kodlar = new StringBuilder();
String satir;
while ((satir = oku.readLine())!=null)//döngü ile sayfadaki kodları alma
{
kodlar.append( satir+"\n");//Satir satır kodları ekleme
}
Log.e("HTML",kodlar.toString());
JSONArray json_dizi = new JSONArray(kodlar.toString());
And I have this error on logcat :
04-20 15:58:41.233 2598-23393/com.not.tuncozer.not E/Error!: Value of type java.lang.String cannot be converted to JSONObject